Skip to content

Commit

Permalink
Revert: allow users to disable broker heartbeats by not providing a t…
Browse files Browse the repository at this point in the history
…imeout (#2097, #2016)
  • Loading branch information
FrankK-1234 authored and auvipy committed Sep 5, 2024
1 parent f3ccc31 commit 33490ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions kombu/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,10 @@ def consume(self, limit=None, timeout=None, safety_interval=1, **kwargs):
try:
conn.drain_events(timeout=safety_interval)
except socket.timeout:
if timeout:
conn.heartbeat_check()
elapsed += safety_interval
if elapsed >= timeout:
raise
conn.heartbeat_check()
elapsed += safety_interval
if timeout and elapsed >= timeout:
raise
except OSError:
if not self.should_stop:
raise
Expand Down
6 changes: 3 additions & 3 deletions t/unit/test_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def se(*args, **kwargs):
next(it)
c.connection.heartbeat_check.assert_called()

def test_consume_drain_no_heartbeat_check(self):
def test_consume_drain_heartbeat_check_no_timeout(self):
c, Acons, Bcons = self._context()
c.should_stop = False
it = c.consume(no_ack=True, timeout=None)
Expand All @@ -102,13 +102,13 @@ def se(*args, **kwargs):
c.connection.drain_events.side_effect = se
with pytest.raises(StopIteration):
next(it)
c.connection.heartbeat_check.assert_not_called()
c.connection.heartbeat_check.assert_called()

it = c.consume(no_ack=True, timeout=0)
c.connection.drain_events.side_effect = se
with pytest.raises(StopIteration):
next(it)
c.connection.heartbeat_check.assert_not_called()
c.connection.heartbeat_check.assert_called()

def test_Consumer_context(self):
c, Acons, Bcons = self._context()
Expand Down

0 comments on commit 33490ad

Please sign in to comment.