[mod_python] Re: PyThreadState_Swap(NULL)

Bryan belred at gmail.com
Sun Aug 20 00:07:29 EDT 2006

Graham Dumpleton wrote:
>> For a start, which version of mod_python are you using? There were some
>> important changes in mod_python 3.2.8 to allow third party modules for
>> Python to work properly where those third party modules used the simple
>> GIL API for thread management.
> Whoops, that should be mod_python 3.2.10. Not 3.2.8.
> Graham


i guess i just don't understand something.  i thought the following code could 
never fail.  wouldn't PyThreadState_Swap(NULL) return either a new python 
interpreter or the one in the current process if it already exists?  what 
interaction with mod_python could there be to cause a conflict with this code? 
i've also commented out the PyEval_InitThreads() function just in case, but it 
still fails.

if (!Py_IsInitialized()) {

g_py_main_interpreter = PyThreadState_Swap(NULL);
if (g_py_main_interpreter) {
      log("PyThreadState_Swap(NULL) succeeded");
else {
      log("PyThreadState_Swap(NULL) failed");


More information about the Mod_python mailing list