Producer/consumer Queue "trick"

Nick Coghlan ncoghlan at iinet.net.au
Sat Jan 15 11:33:46 EST 2005


Paul Rubin wrote:
> Evan Simpson <evan at tokenexchange.com> 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!).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list