[Pyrex] acquiring the GIL?

Victor Ng crankycoder at gmail.com
Thu Feb 23 20:59:08 CET 2006


I'm a little new at integrating C code that needs callback functions to
Python and I'm not quite sure what the correct way to acquire the GIL is.

in my callback function I've got:

cdef void someCallback(char *blah):
   PyGILState_Ensure()
   # do stuff
   PyGILState_Release()

How do I properly write the pxd file to expose the pystate.h functions to
grab the GIL?

I'm confused by stuff like:

PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void);

Do I have to translate PyAPI_FUNC and PyGILState_STATE into Pyrex ctypedef
declarations?

vic

--
"Never attribute to malice that which can be adequately explained by
stupidity."  - Hanlon's Razor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.copyleft.no/pipermail/pyrex/attachments/20060223/a73343b7/attachment.html


More information about the Pyrex mailing list