[Pyrex] pyrex and GIL
Bob Ippolito
bob at redivi.com
Wed Feb 18 15:51:59 CET 2004
On Feb 18, 2004, at 12:03 AM, Simon Burton wrote:
> On Wed, 18 Feb 2004 17:39:32 +1300 (NZDT)
> Greg Ewing <greg at cosc.canterbury.ac.nz> wrote:
>
>> Bob Ippolito <bob at redivi.com>:
>>
>>> 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
>>
>> If the GIL is not held when the callback is called, there
>> will certainly be problems, whether threads are involved
>> or not. The above will need to be done in that case.
>>
>> I don't know enough about threads to say whether they
>> introduce any added complications, though.
>>
>> By the way, I have a feature in mind for some future
>> version that may help with GIL issues. In the meantime
>> you'll have to make the necessary calls yourself.
>>
>
> I have been able to fix this problem by editing the generated c code,
> and sticking the PyEval_ReleaseThread
> just before the return. One must have the GIL to do all the
> DECREF cleanup stuff at the end.
>
> Ahhh, maybe I can use a double callback mechanism, with the outer
> callback just
> handling the GIL stuff, without any python variables to DECREF.
That is exactly what I meant.. two functions, one to manage the GIL,
and one to do whatever you need to do.
-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/20040218/d07c0fdc/smime.bin
More information about the Pyrex
mailing list