[mod_python] handler module loading/execution phases

Alessandro de Manzano demanzano at playstos.com
Tue Oct 13 07:05:21 EDT 2009


Hello,

I'm using ModPyhton 3.3.1 with Apache 2.2.13 and I'm developing a simple 
RESTful-like custom webservice.

All is working correctly, but I'm investigating some "optimization" issues.

In particular, it's not clear to me when/how modpython 
(re)loads/(re)imports the handler's own .py module.

I mean, something like that:


testdummy.py:

DUMMY = 0

def handler(req):
	global DUMMY
	apache.log_error("dummy = %d" % DUMMY, apache.APLOG_ERR, req.server)
	DUMMY += 1

	[etc etc. simple req.write() etc.]


"testdummy.py" is configured in Apache as PythonHandler:
     [..]
     AddHandler mod_python .py
     PythonHandler testdummy
     PythonDebug On # just for debug
     PythonAutoReload On # just for debug


I was expecting to see "dummy = n" where n > 0 sometime in the log.. As 
soon as the same apache process get executed again it should maintain 
the global variable, I tought.
Since this does NOT happens (verified after about 100s requests) I guess 
the "testdummy.py" module is re-evaluated EVERY single time, for every 
and each request.
I am right ? or where am I wrong ?
I read the docs but apparently did not find a description of this issue

Where can I read about the procedures/phases of module 
loading/evaulating of handlers ?


Any hints is welcomed!

Thanks in advance


A. de Manzano
Milano


More information about the Mod_python mailing list