[Pyrex] pyrex and GIL

Bob Ippolito bob at redivi.com
Wed Feb 18 05:10:20 CET 2004


On Feb 17, 2004, at 11:01 PM, Simon Burton wrote:

> I'm using a "cdef" function as a callback routine for a library
> that calls from a different thread.
> The callback uses a PyEval_AcquireThread/PyEval_ReleaseThread pair.
> So far I've got it to work, sort of.
>
> I'm running into problems to do with exception handling*. It would be 
> nice
> to have exceptions work so I can see what's going wrong in the 
> callback.
> A try/except doesn't catch anything. The offending call is to a 
> numarray routine.
>
> I may need to have PyEval_ReleaseThread called after
> all pyrex's clean up stuff, which is supposed to be called with the 
> GIL held.
>
> Any suggestions/workarounds?

Have you tried using a callback function that looks like:

cdef callback:
	acquire GIL
	call the 'actual' function (maybe not even a cdef) that might throw an 
exception
	release GIL

-bob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2357 bytes
Desc: not available
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20040217/7ee9ddce/smime.bin


More information about the Pyrex mailing list