[mod_python] Reload scripts without restarting Apache?

Daniel J. Popowich dpopowich at mtrsd.k12.ma.us
Mon Feb 9 12:16:30 EST 2004


Michael C. Neel writes:
> > Sure is and I'm going to use it for development!!  The problem with
> > doing manual reloads, conditional on some debugging state, is the
> > complexity involved when you have deeply nested modules.  In the app
> > I'm developing, I'm currently doing a lot of tweaking of code in a
> > module imported a few modules down the pipe, as it were.  It's really
> > HARD to get the re-importing logic down there AND it really doesn't
> > want to be there because one of the intermediate modules has no
> > knowledge of being used via mod_python.  Or maybe you're using a
> > third-party module that allows plugins and you're working on the
> > plugin -- you don't want to modify the third-party module to do
> > conditional reloads -- UGLY!
> > 

> I believe you should be able to import any module you want in your
> handler module, even if the handler doesn't use the module directly, and
> have reload() work as expected.  This way you can keep any special debug
> flag action in the handler module and the other modules never need to
> know.

But there are so many caveats to using reload() (see the python doc
for the builtin, but in particular the use of from ... import ...)
that I find I almost always need to restart apache.  For certain
development situations (lots of tweaks to buried modules)
MaxRequestsPerChild set to 1 is perfect for *me* and perhaps for
others.  IMHO, worthwhile enough to mention it in the FAQ as one way
to handle this problem.

Daniel




More information about the Mod_python mailing list