reloadAll now raises exception if any modules fail to reload

This commit is contained in:
Luke Campagnola 2012-06-21 21:24:44 -04:00
parent 3fc741abdc
commit 7ada1ede4a

View File

@ -34,6 +34,7 @@ def reloadAll(prefix=None, debug=False):
- Skips reload if the file has not been updated (if .pyc is newer than .py) - Skips reload if the file has not been updated (if .pyc is newer than .py)
- if prefix is None, checks all loaded modules - if prefix is None, checks all loaded modules
""" """
failed = []
for modName, mod in list(sys.modules.items()): ## don't use iteritems; size may change during reload for modName, mod in list(sys.modules.items()): ## don't use iteritems; size may change during reload
if not inspect.ismodule(mod): if not inspect.ismodule(mod):
continue continue
@ -58,7 +59,10 @@ def reloadAll(prefix=None, debug=False):
reload(mod, debug=debug) reload(mod, debug=debug)
except: except:
printExc("Error while reloading module %s, skipping\n" % mod) printExc("Error while reloading module %s, skipping\n" % mod)
failed.append(mod.__name__)
if len(failed) > 0:
raise Exception("Some modules failed to reload: %s" % ', '.join(failed))
def reload(module, debug=False, lists=False, dicts=False): def reload(module, debug=False, lists=False, dicts=False):
"""Replacement for the builtin reload function: """Replacement for the builtin reload function: