added _cleanup(), a function called if present on a module before being unloaded.

This commit is contained in:
jesopo 2016-04-18 16:47:12 +01:00
parent 9c5f0d6035
commit 2015b1971c
No known key found for this signature in database
GPG key ID: 0BBDEB2AEFCFFCB3

View file

@ -71,6 +71,8 @@ class ModuleManager(object):
# this is such a bad idea
module._is_unloaded = True
self.unhook_check(self.bot.events)
if hasattr(module, "_cleanup"):
module._cleanup()
del sys.modules[module._import_name]
del self.modules[module._name]
del module