Put vital unload code in a finally block
This commit is contained in:
parent
74458520db
commit
a5584de41f
@ -144,13 +144,9 @@ class PluginRef(object):
|
|||||||
if self.pluginModule is None:
|
if self.pluginModule is None:
|
||||||
return
|
return
|
||||||
module = self.pluginModule
|
module = self.pluginModule
|
||||||
self.pluginModule = None
|
|
||||||
try:
|
try:
|
||||||
self.unregisterModule()
|
self.unregisterModule()
|
||||||
for k, v in sys.modules.iteritems():
|
|
||||||
if v is module:
|
|
||||||
sys.modules.pop(k)
|
|
||||||
log.info("Removed module %s from sys.modules", k)
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.unloadError = sys.exc_info()
|
self.unloadError = sys.exc_info()
|
||||||
@ -158,6 +154,12 @@ class PluginRef(object):
|
|||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
self.unloadError = None
|
self.unloadError = None
|
||||||
|
finally:
|
||||||
|
self.pluginModule = None
|
||||||
|
for k, v in sys.modules.iteritems():
|
||||||
|
if v is module:
|
||||||
|
sys.modules.pop(k)
|
||||||
|
log.info("Removed module %s from sys.modules", k)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user