[mod_python] PythonAutoReload Problem

Graham Dumpleton graham.dumpleton at gmail.com
Wed Jul 11 23:18:10 EDT 2007


On 12/07/07, ron banks <rebcoair at cfl.rr.com> wrote:
> Hi Chris,
>
> I'll let someone else set you straight on this but if you search this
> mailing list you will find that it is best to always restart Apache to
> be sure that you have the most current code module loaded. If you don't
> my understanding is that you can't be sure. I know this because I just
> researched it recently myself for the same reasons. I'm sure someone
> will correct me if I am misspeaking.

In mod_python 3.3 there is now a clear line between standard Python
modules and packages which are found by searching sys.path, and those
Python code file modules which are found in the document tree and on
the module importer path. Modules and packages which are found on
sys.path are never reloaded, so making changes to them will always
require a full restart of Apache. The PythonAutoReload directive
doesn't in any way affect importing of those modules and packages.

Python code file modules in the document tree which contain mod_python
handlers, or which contain mod_python.publisher published functions
and data are however candidates for module reloading. In mod_python
3.3 the module importer is smart enough to track parent/child
relationships between modules and thus even know to reimport a parent
module when the child has changed.

In summary, if using version of mod_python prior to 3.3, it wasn't
always predictable and thus full restarts were often required. In
mod_python 3.3, if you setup you application code such that the
mod_python module importer is always used to import it, then you can
go quite a fair way in changing code and not having to do a full
restart, with mod_python automatically reloading modules as necessary.

For further reading, consult documentation for import_module() in:

  http://www.modpython.org/live/current/doc-html/pyapi-apmeth.html

For a long list of problems solved in mod_python 3.3 in respect of
module importing, see:

  http://www.dscpl.com.au/wiki/ModPython/Articles/ModuleImportingIsBroken

Graham

> PythonAutoReload is on by default by the way. This directive is there to
> give you the option to turn it off.
>
>
> Ron
>
> On Wed, 2007-07-11 at 09:00 -0700, Chris wrote:
> > I noticed that sometimes I have to restart Apache before my changes
> > are visible in the browser. I then learned that "PythonAutoReload On"
> > should fix this. However, my problem is that the URL being requested
> > is not a file that was updated so it's not automatically reloading.
> > Does anyone know any tricks to get around this?
> >
> > Thanks,
> > Chris
> >
> >
> >
> > ______________________________________________________________________
> > Get the free Yahoo! toolbar and rest assured with the added security
> > of spyware protection.
> > _______________________________________________
> > Mod_python mailing list
> > Mod_python at modpython.org
> > http://mailman.modpython.org/mailman/listinfo/mod_python
>
> _______________________________________________
> 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