Re: Pyrex Digest, Vol 53, Issue 6

Claudio Freire <[email protected]> Mon, 1 Jun 2009 13:48:22 -0300
Newsgroups gmane.comp.python.pyrex
Message-ID <[email protected]>
horace wrote:

>    hi,
>    it would be great if i could use c-methods for callbacks but i always get a crash if i access self.
>    am i doing something wrong or doesn't self get assigned correctly if the method gets called from a c-library?

I believe your problem is with the GIL - callbacks could and probably
will be called from either threads without the proper threadlocal
structures initialized in python, or without having acquired the GIL
(global interpreter lock).

You'll have to brows Cython/Pyrex docs, I believe there was a way to
acquire the GIL explicitly but I don't recall the details right now -
or you can use the Python/C API directly from Cython/Pyrex which is
rather simple as well.