From b678e92cb0aec20d1e945e28f94238022f01362a Mon Sep 17 00:00:00 2001 From: Patrick Armstrong Date: Mon, 7 Jan 2013 14:47:27 -0800 Subject: [PATCH] Disable heartbeats by default --- dashi/__init__.py | 5 ++++- dashi/tests/test_dashi.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dashi/__init__.py b/dashi/__init__.py index 93d06dd..a6f8a59 100644 --- a/dashi/__init__.py +++ b/dashi/__init__.py @@ -17,7 +17,7 @@ log = logging.getLogger(__name__) -DEFAULT_HEARTBEAT = 30 +DEFAULT_HEARTBEAT = None # Disabled for now class DashiConnection(object): @@ -295,6 +295,9 @@ def _consume_one(self, timeout=None): inner_timeout = timeout - elapsed def heartbeat(self): + if self._dashi._heartbeat_interval is None: + return + time_between_tics = timedelta(seconds=self._dashi._heartbeat_interval / 2) if self._dashi.consumer_timeout > time_between_tics.seconds: diff --git a/dashi/tests/test_dashi.py b/dashi/tests/test_dashi.py index 8383f61..5cd669c 100644 --- a/dashi/tests/test_dashi.py +++ b/dashi/tests/test_dashi.py @@ -372,7 +372,7 @@ def test_handle_sender_kwarg(self): def test_heartbeats(self): receiver = TestReceiver(uri=self.uri, exchange="x1", - transport_options=self.transport_options) + transport_options=self.transport_options, heartbeat=30) receiver.conn.consumer_timeout = 100 receiver.handle("test1", "hello", sender_kwarg="sender")