Raise a KeyError exception if trying to stop a component that hasn't
isn't registered
This commit is contained in:
parent
c8f2173a04
commit
78f9f22a40
|
@ -252,11 +252,20 @@ class ComponentRegistry(object):
|
||||||
sucessfully stopped
|
sucessfully stopped
|
||||||
:rtype: twisted.internet.defer.Deferred
|
:rtype: twisted.internet.defer.Deferred
|
||||||
|
|
||||||
|
:raises KeyError: if a component name is not registered
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not names:
|
if not names:
|
||||||
names = self.components.keys()
|
names = self.components.keys()
|
||||||
elif isinstance(names, str):
|
elif isinstance(names, str):
|
||||||
names = [names]
|
if names in self.components:
|
||||||
|
names = [names]
|
||||||
|
else:
|
||||||
|
raise KeyError("%s is not a registered component!" % names)
|
||||||
|
|
||||||
|
for name in names:
|
||||||
|
if name is not in self.components:
|
||||||
|
raise KeyError("%s is not a registered component!" % name)
|
||||||
|
|
||||||
deferreds = []
|
deferreds = []
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue