[mod_python] PythonAutoReload?

Malcolm Lockyer maxp at orcon.net.nz
Mon Aug 23 17:53:51 EDT 2004


Thanks for the reply.


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, 
with the reloading and with all the server directives set to 1 - it 
started alternating between the two outcomes (obviously apache has a 
sense of humor :P). I currently can't figure out weither the actual 
updating is triggered by the number of refreshes, or the time - since I 
havn't had any reproducable results with either. Seems to range between 
40 seconds and 1min 30, and 60 and 170 refreshes. Its like its picking a 
random number of time and requests and actually reloading the module 
when either of them is reached (even though I know its not, thats what 
it looks like). Also after re-reading the documentation again it says: 
"""By default, mod_python checks the time-stamp of the file and reloads 
the module if the module's file modification date is later than the last 
import or reload. This way changed modules get automatically reimported, 
eliminating the need to restart the server for every change."""

So I've checked the time on my linux box, and ntp is still functioning 
properly. The time differnce between my two machines is <1 second as far 
as I can tell. Also the file modify time (with ls) is clearly earlier 
than the current "date" - and it still doesn't reload.

Its just mocking me now :S...

Anyhow - enough time wasted, guess I'll be restarting apache alot. 
Thanks for your help though.

:'(

M


Byron Ellacott wrote:

> Malcolm Lockyer wrote:
>
>> from mod_python import apache
>> from application import Authentication
>> I noticed the PythonAutoReload directive, even though it defaults to 
>> on, I added it to my .htaccess with no change. Also there isn't just 
>> a .pyc in the application folder I can delete.
>
>
> I'm not sure if this is really what goes on, but I believe the 
> PythonAutoReload directive tells mod_python that when it needs a 
> module to handle a request, it should automatically reload any changed 
> modules.
>
> This doesn't tell Python itself that all imports should reload changed 
> modules.
>
> There are two solutions here.  The first is to configure your Apache 
> process to be more conducive to debugging: MaxRequestsPerChild of 1, 
> or start it in single process mode, or something similar.  The second 
> is to use:
>
> from application import Authentication
> if DEBUG_ON: reload(Authentication)
>
> I'd probably go with the first solution, if practical.
>



More information about the Mod_python mailing list