embedding: forcing an interpreter to end

Peter Hansen peter at engcorp.com
Wed Dec 22 10:20:28 EST 2004

pdectm at yahoo.com wrote:
> Well, the app is multi-threaded, so I do have a big issue getting
> control back to my C program.  I just can not seem to cleanly stop the
> interpreter.  The best I could do is:
> void terminateInterpreter( PyInterpreterState *interp )
> PyThreadState_SetAsyncExc(interp->tstate->thread_id, exc);
> Py_DECREF(exc);

As I recall, there is a return value from SetAsyncExc()
which according to the documentation you *must* check
and handle appropriately if you want to avoid some
unspecified Bad Things from happening.

There was some recent (2-3 weeks ago?) discussion in the
newsgroup/mailing list about this as well, if you want
to check the archives.


More information about the Python-list mailing list