Christian Heimes wrote:
> Stefan Behnel wrote:
>> BTW, are you sure that threading support has been initialised in your
>> program? Just a wild guess, but maybe "import threading" at module level
>> helps? If so, we may be able to fix that.
> 
> I suspect the thread doesn't have a valid thread state. Python needs a
> PyThreadState for every thread that runs Python code. You have to call
> PyThreadState_New() inside the thread exactly once. The code in
> Modules/threadmodule.c shows you how.

Ah, yes, that's possible. So the idea would be to write a nogil function as
callback, to do all the thread-state initialisation and cleanup manually in
there, and then you can call into a with-gil function in between. Although
that might look somewhat hackish all in all.

I don't think Cython can do much to improve this, as it cannot know the
interpreter reference to use for tread-state creation. That has to be done
in user code.

Stefan

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to