[Pyrex] GIL question

Bob Ippolito bob at redivi.com
Wed Oct 6 21:00:22 CEST 2004


On Oct 6, 2004, at 2:51 PM, Phillip J. Eby wrote:

> At 11:36 AM 10/6/04 -0700, Cory Dodt wrote:
>
>> Does Pyrex provide any way to release the GIL?

<PyEval_SaveThread() / PyEval_RestoreThread() example>

> I pretty much translated the above straight from "8.1 Thread State and 
> the Global Interpreter Lock" in the Python/C API manual.  Note, 
> however, that you should only invoke the functions if thread support 
> is present.  (#ifdef WITH_THREAD), so you may need to actually use a 
> different header file, with something like this in it:

Thread support is always present in this case so that is not an issue.  
However, the problem is the opposite of what was previously described.  
cfreactor has its callbacks called without the GIL so they need to 
acquire the GIL, run Python code, and release the GIL... without 
generating any exception blocks, reference counting, etc. after the 
PyGILState_Release().

-bob




More information about the Pyrex mailing list