re-importing modules

Graham Dumpleton Graham.Dumpleton at gmail.com
Tue May 1 02:16:54 EDT 2007


On May 1, 3:51 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> Graham Dumpleton <Graham.Dumple... at gmail.com> writes:
> > That it doesn't reload a parent when a child changes may be fine in an
> > interactive debugger, but can cause problems if not done where
> > automatic reloading is being done in a long running web application
> > where you want to avoid server restarts.
>
> Oh that sounds horrid.  If you really have to do something like that,
> it's time to consider adding serious hot-patching capability as I
> believe Erlang has done.  Better is to start a new server process and
> transfer the live session data and active connections to it through
> IPC mechanisms.  I've had an open RFE for many years (#814689) about
> ancillary messages on AF_UNIX sockets, which let you pass file
> descriptors (such as those attached to open TCP connections) between
> processes.  It actually came up in conversation with someone about
> something I'm currently working on, so maybe I'll have reason to try
> coding it sometime soon (that's not at all definite though).

It may sound horrible but mod_python's original module importer had
lots of problems because of things not being reloaded when they should
have in a consistent manner. People weren't going to want to give up
the reload feature altogether as restarting Apache all the time is
viewed as a worse solution, so the only practical solution was at
least make it reliable and this is one of the things that was required
to do it. The number of complaints against mod_python module importing
and reloading problems has basically vanished now with mod_python 3.3
and the whole thing is so much more stable now.

Do note that this reloading mechanism isn't applied across all Python
modules, only mod_python handler and associated modules which are used
within the context of URL/document space of your web server. Thus it
is quite specialised and has quite specific use case scenarios which
are well understood. In that context the whole mechanism works fine.
Thus, please try not to pass judgment on it without full understanding
the problem space it operates in and how it internally works. :-)

Graham




More information about the Python-list mailing list