[mod_python] Modules not reloading when changed

Gregory Trubetskoy grisha at modpython.org
Wed May 31 09:17:51 EST 2000

On Wed, 31 May 2000, Alexis Iglauer wrote:

> Is there a way to force mod_python to reload the .py
> modules?  I am not using PythonNoReload.

Unfortunately, mod_python has no way of controlling what modules your
scripts will be importing and making them reload.

There are a few ways to force a reload of modules that have changed and
are imported "indirectly":

1. The obvious - restart the server. 

2. The not so obvious - invoke the module that needs reloading directly
via a URL.  This will produce an error, but will force the module to
reload. This doesn't work too well when the module is not in one of the
WWW accessible directories because you will get a "File not found".

Another catch with this approach is that you will have to do this as many
times as there are apache server processes currently running.

3. Recommended approach. Create a debug flag in your scripts and do a
reload when it is on:


import mymodulea
import mymoduleb
import string
import cgi

	mymodulea = reload(mymodulea)
	mymoduleb = reload(mymoduleb)

When you're done debugging, you set DEBUG to 0 or None.



More information about the Mod_python mailing list