[mod_python] [patch] make autoreload more useful

Ian Clelland ian at veryfresh.com
Wed May 29 15:57:38 EST 2002

> 2. One other difficulty: some modules actually *do* want to have global
> state.  For example, a MySQL interface should be able to establish its
> connection once and maintain that through many requests.

But in general, you can't guarantee this in *any* situation. All of the 
modules have to work properly when none of their resources are 
installed (say, on server startup,) and they have to be prepared to die 
at any point.

Usually, persistent connections are used for performance reasons only; 
the modules would otherwise be perfectly happy re-opening every 
database connection on every hit.

This auto-reload feature should only be used during development anyway, 
so performance issues like this shouldn't be a problem (turn it off 
during heavy load testing, of course), and it would be much easier than 
completely restarting the web server after every source file change, 
which is what I'm currently doing.

> Perhaps there should be a mechanism for a module to say "don't remove 
> me!", or at least "preserve the value of this variable".

I don't think this is possible in the general case (and I'm pretty sure 
Python doesn't support it). What would happen if a new version of the 
source file uses a different name for the variable? Or worse, uses the 
same variable (name) for a completely different purpose?

<ian at veryfresh.com>

More information about the Mod_python mailing list