Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert: allow users to disable broker heartbeats by not providing a timeout (#2097, #2016) #2104

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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