[ZODB-Dev] RE: [Zope] Re: Squid headaches

Tim Peters tim at zope.com
Sun Jun 1 23:41:31 EDT 2003


[Dieter Maurer]
> In other (i.e. non-Zope) code, I saw code like:
>
> 	 lock.release()
> 	 sleep(0) # indicate, threads should switch, if necessary
> 	 lock.acquire()
>
> Of course, "sleep(0)" may not force a thread switch on all platforms.

sleep(0) definitely forces a thread to yield its timeslice on Windows,
definitely does not on Solaris, and "beats me" for everything else.  Windows
is happy to switch threads frequently without this kind of trickery, though.

> My lock time optimization holds the lock only while it decides
> whether it has finished. It looks like:
> ...

Sorry, I don't know the packing code well enough to comment.




More information about the ZODB-Dev mailing list