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

start() will throw RuntimeError if called more than once

parent f7ab6e1b
No related branches found
No related tags found
No related merge requests found
......@@ -133,7 +133,16 @@ class Cluster(object):
It is not safe to fork after this.
:param wait: block until connection is ready
:raise RuntimeError: called more than once
"""
try:
self.listener
except AttributeError:
pass
else:
raise RuntimeError(u'This was already called!')
self.listener = ListenerThread()
self.attache_group = AttacheGroup()
......
# coding=UTF-8
from __future__ import print_function, absolute_import, division
import six
import unittest
import time, logging, threading, monotonic
from coolamqp.objects import Message, MessageProperties, NodeDefinition, Queue, ReceivedMessage, Exchange
from coolamqp.clustering import Cluster, MessageReceived, NothingMuch
import time
NODE = NodeDefinition('127.0.0.1', 'guest', 'guest', heartbeat=20)
logging.basicConfig(level=logging.DEBUG)
class TestConnecting(unittest.TestCase):
def test_start_called_multiple_times(self):
c = Cluster([NODE])
c.start(wait=True)
self.assertRaises(RuntimeError, lambda: c.start())
c.shutdown(wait=True)
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