Restarting embedded Python + extensions

paul at fxtech.com paul at fxtech.com
Sat Feb 17 11:31:03 EST 2001


I have Python embedded in a C++ app using Python scripts as extension 
modules. When testing extension scripts I want to be able to restart 
the Python session from scratch and reload all the modules, so I was 
trying to call Py_Finalize() followed by Py_Initialize(). This causes 
a crash (at least for Windows, 2.1 alpha, debug) in the builtin setup 
step in Py_Initialize().

So I was thinking of using a PyThreadState and Py_NewInterpreter() to 
run my extension scrips, and when I want to restart my extensions just 
call Py_EndInterpreter() and Py_NewInterpreter and reload my extension 
modules under the new interpreter.

Does this sound like the right approach?






More information about the Python-list mailing list