diff --git a/coolamqp/clustering/cluster.py b/coolamqp/clustering/cluster.py index 81c4629f47462266f42871dcaa047ec711b2e508..497b93857e8df6cab41138ff1e5cdd8fe699a1b1 100644 --- a/coolamqp/clustering/cluster.py +++ b/coolamqp/clustering/cluster.py @@ -50,7 +50,6 @@ class Cluster(object): self.node, = nodes - def declare(self, obj, persistent=False): """ Declare a Queue/Exchange @@ -175,7 +174,14 @@ class Cluster(object): """ Terminate all connections, release resources - finish the job. :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') self.listener.terminate() diff --git a/tests/test_clustering/test_things.py b/tests/test_clustering/test_things.py index daef9f23b5918fad9c62dfda276fe322b700d09c..fd35acfa5de756e1cf74c00796a831e406c21acf 100644 --- a/tests/test_clustering/test_things.py +++ b/tests/test_clustering/test_things.py @@ -19,3 +19,8 @@ class TestConnecting(unittest.TestCase): c.start(wait=True) self.assertRaises(RuntimeError, lambda: c.start()) c.shutdown(wait=True) + + + def test_shutdown_without_start(self): + c = Cluster([NODE]) + self.assertRaises(RuntimeError, lambda: c.shutdown())