Reentrancy of Python interpreter

bvukov at yahoo.com bvukov at yahoo.com
Sat Sep 29 03:34:38 EDT 2007


On Sep 28, 11:31 pm, Brad Johnson <Brad.John... at ballardtech.com>
wrote:
> I have embedded a single threaded instance of the Python interpreter in my
> application.
>
> I have a place where I execute a Python command that calls into C++ code which
> then in turn calls back into Python using the same interpreter. I get a fatal
> error which is "PyThreadStage_Get: no current thread."
>
> I guess I understand why I can't have two invocations of the same interpreter
> thread in one call stack, but how would I go about solving this?

Looks like ( from PyThreadStage_Get error ) that you lost the GIL. You
probably
entered some C++ code and encapsulated you're work in the

Py_BEGIN_ALLOW_THREADS
<code>
Py_END_ALLOW_THREADS

but you're <code> is calling back the Python function, and you forgot
to acquire
back the GIL.




More information about the Python-list mailing list