[mod_python] Multiple simultaneous requests during server startup

Stéphane Bidoul stephane.bidoul at softwareag.com
Wed Aug 25 20:07:15 EDT 2004


Hi Grisha,

On Windows, when you start (or restart) an Apache instance while
multiple clients are attempting to connect, it seems that
serveral threads import the PythonHandler module simultaneously,
which leads to many kinds of weird behaviours and general
unstability.

You can reproduce with the following PythonHandler:

import time, os, thread
from mod_python import apache

f = open("c:/test.log","a")
print >> f, "start import: pid=",os.getpid(),"tid=",thread.get_ident()
time.sleep(1)
print >> f, "end import: pid=",os.getpid(),"tid=",thread.get_ident()
f.close()

def handler(req):
    req.write("hello")
    return apache.OK

When sending several requests in the same second while the
server starts you obtain the following test.log (several 
thread running the import code simultaneously):

start import: pid= 3668 tid= 808
start import: pid= 3668 tid= 4996
start import: pid= 3668 tid= 1404
start import: pid= 3668 tid= 652
start import: pid= 3668 tid= 1108
start import: pid= 3668 tid= 576
end import: pid= 3668 tid= 808

IMHO, the import of the PythonHandler should be executed
at most once for a given subinterpreter.

Is this a problem you can confirm?
If yes, any idea on how to fix it?

Thanks in advance,

-sbi


More information about the Mod_python mailing list