reloading modules question

Syver Enstad syver at NOSPAMcyberwatcher.com
Sat Dec 9 05:25:54 CET 2000


Is it safe to loop through sys.modules.items()
reloading each module, as long as I catch the ImportError?

Am I guaranteed to have all python modules reloaded if I do the loop twice?

import sys
for key, value in sys.modules.items():
    if value:
    try:
         reload(value)
    except ImportError, e:
         print '%s\n' % e

The reason I am asking is that IIS webserver keeps Python in memory so that
it won't use the new versions of python modules I deploy if don't stop and
start the webserver. I can't afford to stop the webserver all the time, so I
am considering ways to reload the python modules while it's running.





More information about the Python-list mailing list