From 8a0fd009e47ec4e715af437cedb3f76d1d96b67a Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 22 Feb 2019 17:58:53 +0000 Subject: [PATCH] Also unload submodules within packages (ModuleManager.py) --- src/ModuleManager.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ModuleManager.py b/src/ModuleManager.py index fb500a87..51557a3e 100644 --- a/src/ModuleManager.py +++ b/src/ModuleManager.py @@ -203,7 +203,13 @@ class ModuleManager(object): module = loaded_module.module del loaded_module.module + 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) referrers = gc.get_referrers(module) del module