Skip to content

Commit

Permalink
Improve periodic heartbeat
Browse files Browse the repository at this point in the history
- Don't heartbeat if we're about to exit anyways
- Remove unnecessary call to is_set
- Handle exceptions in heartbeat just in case
  • Loading branch information
thomasst committed Apr 24, 2024
1 parent 5aed535 commit 6fe6daf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tasktiger/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,11 @@ def _periodic_heartbeat(
queue_lock: Optional[Semaphore],
stop_event: threading.Event,
) -> None:
while not stop_event.is_set():
stop_event.wait(self.config["ACTIVE_TASK_UPDATE_TIMER"])
self.heartbeat(queue, task_ids, log, locks, queue_lock)
while not stop_event.wait(self.config["ACTIVE_TASK_UPDATE_TIMER"]):
try:
self.heartbeat(queue, task_ids, log, locks, queue_lock)
except Exception:
log.exception("task heartbeat failed")

def execute(
self,
Expand Down

0 comments on commit 6fe6daf

Please sign in to comment.