reloading modules question

Syver Enstad syver at NOSPAMcyberwatcher.com
Sun Dec 10 11:05:58 EST 2000


"Martin von Loewis" <loewis at informatik.hu-berlin.de> wrote in message
news:p6qsnnxamtc.fsf at informatik.hu-berlin.de...
> "Syver Enstad" <syver at NOSPAMcyberwatcher.com> writes:
>
> > Is it safe to loop through sys.modules.items()
> > reloading each module, as long as I catch the ImportError?
>
> What do you mean by "safe"? Python will continue to work, if that is
> what you mean.

Yes that's what I mean. I've read statements to the effect that it's unsafe
to reload extension modules.

> > Am I guaranteed to have all python modules reloaded if I do the loop
twice?
>
> No. Reloading a builtin module does not do anything.
That's okay I'm not talking about builtin's or extensions here just python
modules (ie. written in python). Let me rephrase: Am I guaranteed to have
all python source code modules reloaded if I do the loop twice?


> Which of your modules require reloading when they are reused? I
> recommend to redesign the modules so that they act as libraries,
> instead of keeping session state.

I don't understand you here. All modules that are changed require reloading,
or else the changes won't come into play. I don't see what this has to do
with session state.

To clarify: The IIS appears to dynamically link (via COM) to the Python
interpreter and keep it in memory. Therefore, if you don't want to stop the
IIS process (or subprocesses) you'll have to order the interpreter to reload
the Python source or it won't get used.





More information about the Python-list mailing list