Also unload submodules within packages (ModuleManager.py)

This commit is contained in:
jesopo 2019-02-22 17:58:53 +00:00
parent dec3485071
commit 8a0fd009e4

View file

@ -203,7 +203,13 @@ class ModuleManager(object):
module = loaded_module.module module = loaded_module.module
del loaded_module.module del loaded_module.module
del sys.modules[loaded_module.import_name] del sys.modules[loaded_module.import_name]
namespace = "%s." % loaded_module.import_name
for import_name in list(sys.modules.keys()):
if import_name.startswith(namespace):
del sys.modules[import_name]
references = sys.getrefcount(module) references = sys.getrefcount(module)
referrers = gc.get_referrers(module) referrers = gc.get_referrers(module)
del module del module