[mod_python] Using PythonAutoReload

Graham Dumpleton grahamd at dscpl.com.au
Mon Jul 11 17:59:22 EDT 2005


The automatic module reloading scheme doesn't apply to modules which
have been imported using the "import" statement.

Check out the mod_python documentation or "apache.import_module()".
You might also have a read of:

   http://www.dscpl.com.au/articles/modpython-002.html
   http://www.dscpl.com.au/articles/modpython-003.html

to understand what you do need to use on what, when things get
reloaded and various problems.

There have been discussions of late about fixing the module reloading
mechanism with one proposal being that where appropriate that "import"
automatically map onto the module reloading mechanism, but it isn't
there now.

Graham

On 12/07/2005, at 2:24 AM, Roberto Aguilar wrote:

> Hello everyone,
>
> I've been trying to figure out how to develop python web scripts
> without having to restart httpd every time I make a change to a
> module.  I found the directive:
>
> PythonAutoReload
>
> so I explicitly set it to On in httpd.conf.  But, in the following
> script, for example:
>
> ----
> from mod_python import apache
> import test
>
> def handler(req):
>     req.content_type = 'text/plain'
>
>     f = test.foo()
>     req.write('string: %s\n' % (f.getString()))
>
>     return apache.OK
> ----
>
> any modifications to the module "test" (tell getString() to return
> "string1", then change it to return "string2") will not appear
> consistently across all the httpd sub-processes until the server is
> restarted.  It appears this directive only xhecks the modification
> time of the requested module, or in my case, the handler script.
>
> Most of the development I'm doing is within modules so bouncing the
> server each time I make a change is a bit tedious.  Is there some way
> to get mod_python to check the modification time of any module being
> imported?
>
> Thanks!
>
> -Roberto.
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list