reloadAll now raises exception if any modules fail to reload
This commit is contained in:
parent
3fc741abdc
commit
7ada1ede4a
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user