mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 11:35:49 +00:00
[Core] Do not remove components from component registry on shutdown
By removing the components after they shut down, KeyErrors are raised when trying to acccess the component. Unit tests now clear the component registry on tear down.
This commit is contained in:
parent
19d1afdce0
commit
e883bbf10b
3 changed files with 7 additions and 11 deletions
|
@ -385,13 +385,8 @@ class ComponentRegistry(object):
|
|||
:rtype: twisted.internet.defer.Deferred
|
||||
|
||||
"""
|
||||
def on_success(result, key):
|
||||
del _ComponentRegistry.components[key]
|
||||
return succeed(result)
|
||||
|
||||
def on_stopped(result):
|
||||
return DeferredList(map(lambda t: t[1]._component_shutdown().addCallback(on_success, t[0]),
|
||||
self.components.items()))
|
||||
return DeferredList(map(lambda c: c._component_shutdown(), self.components.values()))
|
||||
|
||||
return self.stop(self.components.keys()).addCallback(on_stopped)
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ class BaseTestCase(unittest.TestCase):
|
|||
d = maybeDeferred(self.tear_down)
|
||||
|
||||
def on_teared_down(result):
|
||||
if len(component._ComponentRegistry.components) != 0:
|
||||
warnings.warn("The component._ComponentRegistry.components is not empty after the test finished!: %s" %
|
||||
component._ComponentRegistry.components)
|
||||
component._ComponentRegistry.components.clear()
|
||||
component._ComponentRegistry.dependents.clear()
|
||||
|
||||
return d.addCallback(on_teared_down)
|
||||
|
||||
def set_up(self):
|
||||
|
|
|
@ -69,7 +69,8 @@ class TopLevelResource(Resource):
|
|||
|
||||
|
||||
class CoreTestCase(BaseTestCase):
|
||||
def setUp(self): # NOQA
|
||||
|
||||
def set_up(self):
|
||||
common.set_tmp_config_dir()
|
||||
self.rpcserver = RPCServer(listen=False)
|
||||
self.core = Core()
|
||||
|
@ -94,7 +95,7 @@ class CoreTestCase(BaseTestCase):
|
|||
raise error
|
||||
return result
|
||||
|
||||
def tearDown(self): # NOQA
|
||||
def tear_down(self):
|
||||
|
||||
def on_shutdown(result):
|
||||
del self.rpcserver
|
||||
|
|
Loading…
Add table
Reference in a new issue