[mod_python] Issues in apache MPM mode

Graham Dumpleton grahamd at dscpl.com.au
Mon Aug 22 18:47:33 EDT 2005


On 23/08/2005, at 3:36 AM, Arzola, Nelson wrote:

> My understanding is that mod_python actually starts a unique 
> interpreter for each thread.

When using a multithreaded MPM, the creation of the threads in the
thread pool is handled by Apache and not mod_python/Python. There is no
association of specific threads to specific interpreters within a child
process. Regardless of which thread it is, when mod_python is handed a
request by Apache for processing, it will invoke the handler in whatever
interpreter is appropriate for the URL.

This means that if two requests come in for the same URL at the same
time, then both threads will be routed through to the same handler in
the same interpreter. In other words, there can be more than one thread
executing within the context of a specific interpreter at any one time.
They may be executing the same handler or different handlers.

Upon a subsequent request, these same threads may execute against a
different interpreter if the URL mapped to a part of the URL namespace
managed under the context of a distinct interpreter.

> If you read the message in your log file carefully, it says 
> "(Re)Importing".  You can verify that this is the case by starting the 
> httpd process with -X flag (one process, one thread, do not detach 
> from console).  You should only see one "(Re)Importing" message.

Don't read too much into these messages. All this message is saying is
that a specific module has been loaded for the first time, or if the
automatic reloading option is turned on and the code file changed, that
it is being reloaded.

Unfortunately it doesn't distinguish between these two different cases.
It would be nice if it said "Importing" on the first load and
"Reimporting" on the subsequent reload as it would make things clearer.
It would certainly make it easier to detect when the multithreaded bug
related to interpreter creation and module loading has occurred as more
people might then realise there was a problem due to seeing multiple
"Importing" messages at the same time for the same module in the same
interpreter and search out the fix for the bug rather than just assuming
that mod_python doesn't work or is too hard to get working. :-(

Graham



More information about the Mod_python mailing list