Log when a module is unloaded, including how many references are left to the

module object
This commit is contained in:
jesopo 2018-09-01 18:49:50 +01:00 committed by Dan
parent 0869c17808
commit 1d35cee332

View file

@ -91,4 +91,10 @@ class ModuleManager(object):
self.events.purge_context(event_context) self.events.purge_context(event_context)
del sys.modules[name] del sys.modules[name]
references = sys.getrefcount(module)
del module del module
references -= 1 # 'del module' removes one reference
references -= 1 # one of the refs is from getrefcount
self.bot.log.info("Module '%s' unloaded (%d reference%s)",
[name, references, "" if references == 1 else "s"])