re-importing modules

sjdevnull at yahoo.com sjdevnull at yahoo.com
Tue May 1 11:07:23 EDT 2007


John Nagle wrote:
> Steven D'Aprano wrote:
> > I'd hate for reload to disappear, it is great for interactive
> > development/debugging, at least under some circumstances. (If you have
> > complex and tangled class hierarchies, it might not be powerful enough.)
> >
> > As for the semantics being awful, I disagree. reload() does exactly
> > what it claims to do, no more, no less.
>
>      It's more complicated than that.  See
>
>        http://arcknowledge.com/lang.jython.user/2006-01/msg00017.html
>
> Exactly what reloading should do is still an open question for some of
> the hard cases.
>
>      "reload" as a debug facility is fine.
> Trouble comes from production programs which use it as a
> reinitialization facility.

I tend to agree with this; our servers do graceful restarts to pick up
code changes (which, in addition to avoiding reload also means that
it's easier as an admin to control the view of the code than in
"automatically pick up new changes" models--in particular, you can
wait until all changes are there, send SIGUSR1, and pick up the whole
set of changes atomically).

>      Reloading a module with multiple threads running gets
> complicated.  It works in CPython because CPython doesn't have
> real concurrency.

Point of clarity: the CPython interpreter is not concurrent.
Concurrency != multithreading, and multiprocess solutions run fine in
CPython.




More information about the Python-list mailing list