PyThreadState_Swap difference in 2.3.2?

vincent wehren vincent at visualtrans.de
Mon Dec 15 17:37:46 EST 2003


"Paul Miller" <paul at fxtech.com> schrieb im Newsbeitrag
news:knbstvgsn3o3qmmtu975g8eb94rhpmae2o at 4ax.com...
| I have a C++ application that uses multiple embedded Python interpreters.
I
| allocate multiple interpreters using Py_NewInterpreter, and switch between
| them using PyThreadSate_Swap.
|
| In 2.2.2, this all worked fine.
|
| I just installed 2.3.2, but now the first time I call Py_NewInterpreter,
it
| bails out in PyThreadState_Swap, in the debug checking code, with:
|
| Py_FatalError("Invalid thread state for this thread");
|
| Has the interpreter/thread setup code changed since 2.2?
|
| To be complete, I set up with this:
|
| Py_Initialize();
| PyThreadState *globalState = PyThreadState_Get();
|
| // allocate new interpreter
| PyThreadState *interp = Py_NewInterpreter();

The same thing stumped me too a couple of days ago (s.
http://groups.google.nl/groups?q=PyNew_Interpreter&hl=nl&lr=&ie=UTF-8&oe=UTF-8&selm=braiu1%243r3%241%40news4.tilbu1.nb.home.nl&rnum=1 )
with 2.3.3c1 (same applies 2.4a0 for that matter).

Although I  am sure the following snip in PyThreadState_Swap was put there
for a reason,
it would be great if someone could put some light on the matter....:

 /* It should not be possible for more than one thread state
    to be used for a thread.  Check this the best we can in debug
    builds.
 */
#if defined(Py_DEBUG) && defined(WITH_THREAD)
 if (new) {
  PyThreadState *check = PyGILState_GetThisThreadState();
  if (check && check != new)
   Py_FatalError("Invalid thread state for this thread");
 }
#endif

Regards
Vincent Wehren


|
| I am investigating to see if a crash I used to see with 2.2 is still
around
| in 2.3, where if you call Py_Initialize() and Py_Finalize() multiple times
| it would die.
|
|






More information about the Python-list mailing list