diff --git a/kuyruk/heartbeat.py b/kuyruk/heartbeat.py index 1e009105..7f39089f 100644 --- a/kuyruk/heartbeat.py +++ b/kuyruk/heartbeat.py @@ -27,10 +27,10 @@ def stop(self) -> None: self._thread.join() def _run(self) -> None: - while not self._stop.is_set(): + while not self._stop.wait(timeout=1): try: self._connection.heartbeat_tick() - self._connection.drain_events(timeout=1) + self._connection.drain_events(timeout=0) except socket.timeout: pass except Exception as e: