Skip to content
Snippets Groups Projects
Commit 12d925c7 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

shutdown without start will RuntimeError

parent 2a26d386
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,6 @@ class Cluster(object): ...@@ -50,7 +50,6 @@ class Cluster(object):
self.node, = nodes self.node, = nodes
def declare(self, obj, persistent=False): def declare(self, obj, persistent=False):
""" """
Declare a Queue/Exchange Declare a Queue/Exchange
...@@ -175,7 +174,14 @@ class Cluster(object): ...@@ -175,7 +174,14 @@ class Cluster(object):
""" """
Terminate all connections, release resources - finish the job. Terminate all connections, release resources - finish the job.
:param wait: block until this is done :param wait: block until this is done
:raise RuntimeError: if called without start() being called first
""" """
try:
self.listener
except AttributeError:
raise RuntimeError(u'shutdown without start')
logger.info('Commencing shutdown') logger.info('Commencing shutdown')
self.listener.terminate() self.listener.terminate()
......
...@@ -19,3 +19,8 @@ class TestConnecting(unittest.TestCase): ...@@ -19,3 +19,8 @@ class TestConnecting(unittest.TestCase):
c.start(wait=True) c.start(wait=True)
self.assertRaises(RuntimeError, lambda: c.start()) self.assertRaises(RuntimeError, lambda: c.start())
c.shutdown(wait=True) c.shutdown(wait=True)
def test_shutdown_without_start(self):
c = Cluster([NODE])
self.assertRaises(RuntimeError, lambda: c.shutdown())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment