PyThreadState_Swap(NULL)

B

Bryan

hi,

i've written a program that uses python c api code that lives in a
shared library that is loaded by a custom apache module (mod_xxx). this
python c api code all works correctly under our test server and under
apache but only if mod_python isn't loaded. when apache loads
mod_python as shown in the http.conf snippet below,
PyThreadState_Swap(NULL) in mod_xxx returns NULL. when the snippet of
code in http.conf is commented out, it works again. what do i have to
do to have mod_xxx code work correctly when apache loads mod_python?


failure case when apache loads mod_python:
Py_Initialize() succeeded
PyThreadState_Swap(NULL) failed


sucess case when apache doesn't load mod_python:
Py_Initialize() succeeded
PyThreadState_Swap(NULL) succeeded


thanks,

bryan


--- mod_xxx ---

Py_Initialize();
if (Py_IsInitialized()) {
log("Py_Initialize() succeeded");
}
else {
log("Py_Initialize() failed");
}

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



---- apache's http.conf ----

LoadModule python_module "../apache/bin/mod_python.so"

Listen 4119
<VirtualHost _default_:4119>
<Directory "C:/Program Files/Foo">
SetHandler mod_python
PythonHandler mod_python.publisher
PythonDebug Off
</Directory>
</VirtualHost>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top