473,385 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

PyThreadState_Swap(NULL)

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>

Aug 18 '06 #1
0 1239

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: Francis Avila | last post by:
Below is an implementation a 'flattening' recursive generator (take a nested iterator and remove all its nesting). Is this possibly general and useful enough to be included in itertools? (I know...
0
by: Bryan | last post by:
i've embedded python into our product and i'm not sure how to handle this situation. the following code is a simplification of a function that calls a python function. i've removed all error...
7
by: Paul Miller | last post by:
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,...
0
by: Axel Diener | last post by:
I embed python interpreters in a C++ program. For each script to execute I create a new interpreter. In this environment I can use the win32 extensions only one time. Here is a little piece of...
1
by: Simon Burton | last post by:
AFAICT I am trying to get the GIL from a thread created outside of python, but a deadlock ensues. I have tried python 2.2 and 2.3. I am running this on Linux, and have verified, using a...
1
by: freesteel | last post by:
I have posted about this problem before. SInce then I found a much better article to help with embedding python in a multithreaded application: http://www.linuxjournal.com/article/3641 I...
0
by: Bryan | last post by:
hi, i have a multithreaded c server that calls process_method in a different c thread per each call. process_method calls a python function bar in module foo. function bar calls back into c. ...
0
by: Bryan | last post by:
hi, i'm trying to write a multithreaded embedded python application and i'm having some trouble. i found this article "embedding python in multi-threaded c/c++ applications" in the python...
11
by: sturlamolden | last post by:
Python has a GIL that impairs scalability on computers with more than one processor. The problem seems to be that there is only one GIL per process. Solutions to removing the GIL has always...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.