Producer/consumer Queue "trick"

Nick Coghlan ncoghlan at
Sat Jan 15 11:33:46 EST 2005

Paul Rubin wrote:
> Evan Simpson <evan at> writes:
>>wakes up the producer, which has been blocked waiting to add a board
>>to the Queue.  It sets about generating the next board, and the
>>consumer doesn't get to run again until the producer blocks again or
>>is preempted.
> That's weird.  Preemption should happen every few dozen milliseconds
> unless you've purposely increased the preemption delay.

To me, it smells like a call into a C extension which isn't releasing the GIL 
before starting a time-consuming operation.  After getting bitten by this a 
couple of times, I now make sure to release the GIL as part of my SWIG wrapper 
(since the code I'm wrapping knows nothing of Python, and sure as heck doesn't 
need to be holding the GIL!).


Nick Coghlan   |   ncoghlan at   |   Brisbane, Australia

More information about the Python-list mailing list