Python with Apache 2.0

C

Chang LI

Does python support threads safely along with Apache 2.0 in web applications.

Chang
 
C

Craig Ringer

Chang,
I guess it depends whether you're using Python in a CGI or within
mod_python. Could you give us a little more information, or check the
mod_python documentation?

If it turns out that mod_python can't handle it, perhaps FCGI / SCGI
might be worth examining, too...
 
D

Damjan

Does python support threads safely along with Apache 2.0 in web
applications.

Are you talking about mod_python?
If so, then yes. But note that Apache threads entering the python
interpreter (via mod_python) will be serialized on the GIL.
 
S

Steve Holden

Damjan said:
Are you talking about mod_python?
If so, then yes. But note that Apache threads entering the python
interpreter (via mod_python) will be serialized on the GIL.
This is true, but it doesn't tell the whoel story: mod_python has taken
care to make it possible to configure multiple interpreters - on a
per-directory basis if necessary. Obviously they all share the pure
code, but if I undestand correctly each has its own data space, and
hence its own GIL.

regards
Steve
 
C

Chang LI

Damjan said:
Are you talking about mod_python?
If so, then yes. But note that Apache threads entering the python
interpreter (via mod_python) will be serialized on the GIL.

Yes, use mod_python. I plan to use Python to replace PHP and other
languages. The low efficient CGI will be replaced by embedded Python
program. Apache 2.0 is faviority becuase the threads are must have
features.
 
G

Graham Dumpleton

Does python support threads safely along with Apache 2.0 in web applications.

Yes, but the latest version of mod_python (3.1.3) has a couple of bugs
in it in relation to threads which can cause problems when using a
threaded MPM with Apache. No indication has been given as to when
they will be fixed so you should patch the bugs yourself for now.

You can find some details and the patches at:

http://www.dscpl.com.au/projects/vampire/PATCHES

There is a discussion on the mod_python mailing list archives at:

http://www.modpython.org/pipermail/mod_python/2004-October/thread.html

Look for the thread starting with "Udate python modules without restarting Apache".
It is this discussion which lead to the uncovering of the bugs.
 
T

Tim Roberts

Yes, use mod_python. I plan to use Python to replace PHP and other
languages. The low efficient CGI will be replaced by embedded Python
program. Apache 2.0 is faviority becuase the threads are must have
features.

I would like to point out yet again that CGI isn't as bad as many people
make it out to be. Unless you know you need to handle thousands of
requests per minute, the overhead of creating a process and firing up the
interpreter is not significant.

CGI is certainly an easier debug environment than mod_python or any of the
long-running-process solutions.
 
G

Graham Dumpleton

Steve Holden said:
This is true, but it doesn't tell the whoel story: mod_python has taken
care to make it possible to configure multiple interpreters - on a
per-directory basis if necessary. Obviously they all share the pure
code, but if I undestand correctly each has its own data space, and
hence its own GIL.

There is actually a possible bug in PythonInterpPerDirectory directive
which applies even if threading isn't being used. Specifically, mod_python
doesn't calculate the interpreter name correctly and although access to a
directory by name and something in it should logically resolve to the
same interpreter name it doesn't. More information can be found at:

http://www.modpython.org/pipermail/mod_python/2004-November/016788.html

Overall, I am not sure that PythonInterpPerDirectory is a good idea, but
then it probably was created to workaround the short comings of the
module importing system in mod_python which makes it impossible in
mod_python.publisher to have an index.py file in separate directories
within the context of the one interpreter. It wouldn't take much effort to
fix this limitation in the module importing system, but there doesn't seem
to be much interest in doing so.
 
S

Steve Holden

Graham said:
There is actually a possible bug in PythonInterpPerDirectory directive
which applies even if threading isn't being used. Specifically, mod_python
doesn't calculate the interpreter name correctly and although access to a
directory by name and something in it should logically resolve to the
same interpreter name it doesn't. More information can be found at:

http://www.modpython.org/pipermail/mod_python/2004-November/016788.html

Overall, I am not sure that PythonInterpPerDirectory is a good idea, but
then it probably was created to workaround the short comings of the
module importing system in mod_python which makes it impossible in
mod_python.publisher to have an index.py file in separate directories
within the context of the one interpreter. It wouldn't take much effort to
fix this limitation in the module importing system, but there doesn't seem
to be much interest in doing so.

Thank a lot for the additional information. I agree that the namespace
confusion is less than ideal in mod_python.

regards
STeve
 

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

Forum statistics

Threads
474,211
Messages
2,571,092
Members
47,694
Latest member
digiadvancemarketing

Latest Threads

Top