enhance: allow uses to disable broker heartbeats by not providing a timeout

This commit is contained in:
smart-programmer 2024-05-12 22:27:27 +03:00 committed by Asif Saif Uddin
parent eae75855e0
commit cddc500fd2
1 changed files with 5 additions and 4 deletions

View File

@ -195,10 +195,11 @@ class ConsumerMixin:
try: try:
conn.drain_events(timeout=safety_interval) conn.drain_events(timeout=safety_interval)
except socket.timeout: except socket.timeout:
conn.heartbeat_check() if timeout:
elapsed += safety_interval conn.heartbeat_check()
if timeout and elapsed >= timeout: elapsed += safety_interval
raise if elapsed >= timeout:
raise
except OSError: except OSError:
if not self.should_stop: if not self.should_stop:
raise raise