[Cython] Why is 'with gil' disabled in the parser? Any good reason?
Sturla Molden
sturla at molden.no
Fri Mar 6 14:48:55 CET 2009
On 3/6/2009 7:23 AM, Greg Ewing wrote:
> You'd have to do quite a lot more than that. I don't
> remember all the details,
There is also the simplified GIL API, which only requires two function
calls. This is e.g. how ctypes makes sure the GIL is held in callbacks
to Python.
A 'with gil' block could just expand to:
{
PyGILState_STATE _gilstate = PyGILState_Ensure();
/* now we have the GIL */
PyGILState_Release(_gilstate);
}
Nothing else is required. The simplified GIL API makes sure the function
does not deadlock if the caller already has the GIL. The only
requirement is that a call to PyGILState_Ensure should always have a
matching call to PyGILState_Release.
Sturla Molden
More information about the Cython-dev
mailing list