[mod_python] Udate python modules without restarting Apache

Graham Dumpleton grahamd at dscpl.com.au
Thu Oct 7 18:10:49 EDT 2004

On Oct 07 23:50, berry groenendijk <berry.groenendijk at gmail.com> wrote:
> Subject: Re: [mod_python] Udate python modules without restarting Apache
> My handler is servlet.py. The excellent module build by Daniel
> Popowich. I do not place this servlet.py in the mod_python
> installation directory, but I have the servlet.py in the root of my
> website. In a .htaccess file I have the following entries:
> PythonAutoReload On
> SetHandler mod_python
> PythonHandler servlet
> PythonDebug on
> I think the problem is in the servlet.py. Because, as soon as I touch
> this file I get this error:
> ValueError: index is not a subclass of Servlet (in E:/Program
> Files/Apache Group/Apache2/htdocs/MySite/index.mps)
> Before I touched servlet.py the index file loaded perfectly.
> Apparently apache tried reloading the servlet file effectively
> creating a new Servlet object in memory. Other pages that have already
> created in memory and that are subclasses from Servlet have now
> apparently lost their 'parent'.
> Any suggestions how to solve this?

Hmmm, I haven't tried MPS as yet, looks like it might be time to do so
in order to understand it a bit better.

One of the issues with reloading that isn't obvious is that it doesn't
actually clean out the namespace of the existing loaded module before
loading it again. In effect it lays the reloading module back over the top
of the old one. You can thus still have strange things happen if you keep
state in global variables or remove methods.

The easiest to explain is the removal of a method from a module which
is imported by mod_python.publisher. Even though the method is removed
from the code file, when it reloads the code module it doesn't actually
delete the existing method, so it still exists and can still be accessed by
a request.

Anyway, I'll get down MPS and have a bit of a play.

Graham Dumpleton (grahamd at dscpl.com.au)

More information about the Mod_python mailing list