[mod_python] Force reload?

Daniel Popowich dpopowich at comcast.net
Wed Feb 2 23:16:04 EST 2005


Jon-Pierre Gentil writes:
> 
> Argh!  I wish that mod_python would check all loaded modules for changes 
> as a flat rule, not as a tree...  because currently it will only reload 
> something if I touch the handler, because the reload code sees that the 
> handler hasn't changed and does not bother checking the modules that the 
> handler uses for changes.  Might as well not even use mod_python.import() 
> at all.
> 
> Anyway, is there an option I can use to force the reload of the handler 
> module each and every time a request is made?  I am only needing this for 
> debugging purposes, so I don't mind something that is a bit kludgey.
> 
> Thank you!  And please fix the import issue!

One brute force method which I employ during early stage development
and debugging is an apache configuration tweak.  Assuming for the
moment you're using the prefork MPM:

    <IfModule prefork.c>
    StartServers       8
    MinSpareServers    5
    MaxSpareServers   20
    MaxClients       150
    #MaxRequestsPerChild  1000
    # for debugging mod_python
    MaxRequestsPerChild  1
    </IfModule>

You'll notice where I comment out the default for MaxRequestsPerChild,
1000, and replace it with 1.  This allows each process to only serve
one request before being killed, so I get a fresh interpreter with
each request.  When I'm ready for beta testing I switch back to 1000.

Depending on your development box, this can be slow going, but you
will NEVER be burned by stale imports.

Daniel Popowich
-----------------------------------------------
http://home.comcast.net/~d.popowich/mpservlets/




More information about the Mod_python mailing list