Problems with PyGILState_Ensure () and PyGILState_Release ()

Mathias Mamsch Domoran at yahoo.de
Fri Aug 13 07:49:09 EDT 2004


Hi all,

i am writing a python extension in c++.   In the extension a c++ thread
calls back into python. I did it like this:

---- c++ code ----
PyGILState_STATE gstate;
gstate = PyGILState_Ensure ();

... do some work ...
// call the python callback (Func)
result = PyEval_CallObject(Func, arglist);
... so some cleanup ...

PyGILState_Release (gstate);
return
-----------------

the callback is executed properly, but the PyGILState_Release gives me the
following error:
"Fatal Python error: PyThreadState_Delete: tstate is still current"

What can be wrong here? Any suggestions?
In my understanding this error should not occur ... Is this a known bug
maybe? I am using Python 2.4a1 under windows.

Thanks in advance, Mathias Mamsch






More information about the Python-list mailing list