Skip to content

Commit

Permalink
add comments to heartbeat class
Browse files Browse the repository at this point in the history
  • Loading branch information
cenkalti committed Mar 10, 2018
1 parent 4dfde9c commit e74cc8f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kuyruk/heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ def start(self) -> None:
self._thread.start()

def stop(self) -> None:
"""Make sure this method does not block too long because
it is called from the main worker thread."""
self._stop.set()
self._thread.join()

def _run(self) -> None:
while not self._stop.wait(timeout=1):
try:
# Sends Heartbeat only if necessary
self._connection.heartbeat_tick()
# Processes incoming heartbeats
self._connection.drain_events(timeout=0)
except socket.timeout:
pass
Expand Down

0 comments on commit e74cc8f

Please sign in to comment.