summaryrefslogtreecommitdiff
path: root/buildstream/plugin.py
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-01-16 14:08:31 -0500
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-01-16 16:13:00 -0500
commit66f0d80b564df82d55051f197ba71b283f1ebe31 (patch)
treebaacc7d2919d5d577fce830edf9dcbb7ff2af846 /buildstream/plugin.py
parent1aa803b2883759265b4dbfafd817380be94b846d (diff)
downloadbuildstream-66f0d80b564df82d55051f197ba71b283f1ebe31.tar.gz
plugin.py: Dont create Message() objects in destructor.
These will pass on a plugin unique id which when used to index the plugin will raise KeyError, instead just accept the plugin is dead and print to stdout if in debug mode.
Diffstat (limited to 'buildstream/plugin.py')
-rw-r--r--buildstream/plugin.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/buildstream/plugin.py b/buildstream/plugin.py
index 752c58f0e..9c4ccb16e 100644
--- a/buildstream/plugin.py
+++ b/buildstream/plugin.py
@@ -51,7 +51,10 @@ class Plugin():
self.debug("Created: {}".format(self))
def __del__(self):
- self.debug("Destroyed: {}".format(self))
+ # Dont send anything through the Message() pipeline at destruction time,
+ # any subsequent lookup of plugin by unique id would raise KeyError.
+ if self.__context.log_debug:
+ print("DEBUG: Destroyed: {}".format(self))
def __str__(self):
return "{kind} {typetag} at {provenance}".format(
@@ -529,7 +532,7 @@ __PLUGINS_TABLE = WeakValueDictionary()
def _plugin_lookup(unique_id):
try:
plugin = __PLUGINS_TABLE[unique_id]
- except (AttributeError, KeyError):
+ except (AttributeError, KeyError) as e:
print("Could not find plugin with ID {}".format(unique_id))
raise e