diff --git a/deluge/core/rpcserver.py b/deluge/core/rpcserver.py index e2069360a..93315d4a7 100644 --- a/deluge/core/rpcserver.py +++ b/deluge/core/rpcserver.py @@ -424,6 +424,17 @@ class RPCServer(component.Component): log.debug("Registering method: %s", name + "." + d) self.factory.methods[name + "." + d] = getattr(obj, d) + def deregister_object(self, obj): + """ + Deregisters an objects exported rpc methods. + + :param obj: the object that was previously registered + + """ + for key, value in self.factory.methods.items(): + if value.im_self == obj: + del self.factory.methods[key] + def get_object_method(self, name): """ Returns a registered method. diff --git a/deluge/plugins/pluginbase.py b/deluge/plugins/pluginbase.py index a59aab754..cdabcf6bd 100644 --- a/deluge/plugins/pluginbase.py +++ b/deluge/plugins/pluginbase.py @@ -58,6 +58,9 @@ class CorePluginBase(PluginBase): component.get("RPCServer").register_object(self, plugin_name.lower()) log.debug("CorePlugin initialized..") + def __del__(self): + component.get("RPCServer").deregister_object(self) + class GtkPluginBase(PluginBase): def __init__(self, plugin_name): super(GtkPluginBase, self).__init__("GtkPlugin." + plugin_name)