[mod_python] PythonAutoReload?

Fabio Rotondo mlists at rotondo.it
Mon Aug 23 10:09:09 EDT 2004


Malcolm Lockyer wrote:

> Gah this is frustrating.. so far I've tried ->
> 
> * Reloading the module on each page of the handler
> * Changing the MaxRequestsPerChild to 1
> * Changing the StartServers, MinSpareServers and MaxSpareServers to 1
> 
> With no change. Each approach seemed to slightly modify the behavior, 

Hi Malcolm,

I have the same problem, but I have resolved it in a faster (and much 
more dirty) way: I simply restart Apache every time I have made a change 
in my code that mod_python would not be able to see.

As far as I can tell, there are two kind of files those you'll be pretty 
sure mod_python will reload and those you wont.
For example, in my app, I have some code that goes inside 
/usr/lib/python/site-packages/(mydir)
These files are *not* reloaded by mod_python and when I change them I 
have to restart apache in order to see the changes.

The "plugin" directory, on the other hand, that is not contained inside 
"site-packages" is reloaded every time I hit the "reload" button on my 
browser.

Now, I don't know the logic behind PSP pages or related to your code, 
but you should make some tests and find out when an Apache restart is 
needed.

BTW: keep in mind that (with the standard Apache config) there could be 
more than one single thread that keeps running your app. This means that 
  one thread could have a version of your code more recent/older than 
the other.

You have to restart Apache only while you are developing. I know this 
can be annoying, but it is the only *safe* way I found out to be sure 
that what you write is what you get :-)
Furthermore, once your app is deployed it is handy to have mod_python to 
keep your mods around: your app will run faster.

Hope this helps.

Ciao,

    Fabio



More information about the Mod_python mailing list