![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Programming Guru
![]() |
Okay, since I can at least understand my code, giving potential to changes therein, I'll stick with it.
Thanks though. |
|
|
|
|
|
#22 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Why are you rejecting it? A superior solution has been offered that will run much faster, take up less space, and leave less room for error. If you can't understand it, just ask and it'll be explained.
|
|
|
|
|
|
#23 |
|
Programming Guru
![]() |
Well I felt like I have been pestering Arevos. >_> Which I have.
And it's not necessarily "superior", speed will be different by approximately 1/1 000 000th of a second. And if I understand it, I can at least make changes as seen necessary. @_@ I've implemented my system and it seems to be working fine, working 10 threads. I had to do two differen locking systems though, an extra for the dynamic images. I couldn't have stats being written to the image that's being downloaded by someone. |
|
|
|
|
|
#24 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
If Sane's just saving and loading images, which I suspect he is, he'll probably only need to read or write to a file once before it is closed, so his solution isn't likely to be particularly less efficient than mine.
I think my way's neater - and as Cerulean says, it's a little more robust. But there's a lot to be said for working out a solution on your own, and if Sane's careful, he's not going to run into any problems with his solution.Quote:
|
|
|
|
|
|
|
#25 |
|
Programming Guru
![]() |
Nah, just one system that I posted up above, and then a seperate lock for locking the block of code that creates and serves the dynamic image.
Edit: Wow, I'm happy I noticed this!! =] I had a used except IOError in some places to except if the file didn't exist. But in my function it raises the IOError without ever releasing the lock. This was creating a huge problem in my site, the biggest being you couldn't log in if you hadn't already with the same IP. def read(self):
lock = FileReadWriteLock(self.fname)
lock.acquire_read()
try:
file = open(self.fname, self.ftype)
data = file.read()
file.close()
except IOError:
lock.release_read()
raise IOError
return data
def readlines(self):
lock = FileReadWriteLock(self.fname)
lock.acquire_read()
try:
file = open(self.fname, self.ftype)
data = file.readlines()
file.close()
except IOError:
lock.release_read()
raise IOError
return dataFixed ^^ Last edited by Sane; Feb 20th, 2006 at 8:13 PM. |
|
|
|
|
|
#26 |
|
Programming Guru
![]() |
Post Edit:
I forgot the "lock.release_read()" after the IOError except. >___>;;; I feel so dumb. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|