[Cython] GIL handling C code (was: [cython-users] What's up with PyEval_InitThreads() in python 2.7?)

Stefan Behnel stefan_ml at behnel.de
Tue Feb 28 20:58:23 CET 2012

mark florisson, 28.02.2012 16:35:
> Basically, the cleanup code only needs a matching release because the
> corresponding acquire is in EnsureGILNode, which wraps the function
> body in case of a nogil function with a 'with gil' block. Any changes
> to the conditions in FuncDefNode will have to be reflected by the code
> that does that wrapping. Changing the refnanny macro for the cleanup
> code will not avail anything, as the GIL is already ensured.

Regarding the "with gil" code, ISTM that the "finally" code in the with_gil
test is being duplicated. I noticed this when I moved the refnanny's GIL
state into a block local variable and that broke the C code. Basically, the
with-gil block had declared the variable in its own block, but was then
trying to access that variable in a second finally clause, further down and
outside of the with-gil block.

Looks like a bug to me.


More information about the cython-devel mailing list