[mod_python] Howto force reload of all modules

hhanke at pdx.edu hhanke at pdx.edu
Fri Aug 31 14:21:18 EDT 2007


Quoting Graham Dumpleton <graham.dumpleton at gmail.com>:
> On 31/08/2007, hhanke at pdx.edu <hhanke at pdx.edu> wrote:
>> please, I'm using apache.import_module() to import my modules
>> in mod_python 3.2.8 (I'm stuck with this version on our
>> production server). Since it has its problems, please, what
>> is the easiest way to reload all modules?
> The only reliable way is to restart the whole of Apache.

This just cannot be done on a production sever where multiple
websites run and a server I as a developer have no controll about.

> If it were a development server, you could also use the brute force
> method of having the Apache child process restart after every request.
> This is done using the Apache directive:
>   MaxRequestsPerChild 1
> This should however never be used on a production server, as it would
> give CGI like performance.

It would be acceptable to use it for a short period, e.g. after updating
the website to the new release version, but since I can't do that on
a per-directory basis through .htaccess, it is of no use on a production
server where multiple websites run and I can't edit the global conf.

> In short, there is no good way of doing it.

So how do I use Python for writing more complicated webpages,
that need to use modules (both my own and completely external
that I have no controll about and they use the classical import)?
Do I have to use CGI then?

> Even the module importer in 3.3.1 is only of use to web application
> code which is managed by mod_python and not normal Python modules
> on sys.path.

Hm... Can I somehow force the reload of a given module that I imported
through apache.import_module manually? I mean an equivalent of reload().

Thank you,
Hynek






More information about the Mod_python mailing list