Skip to content

Commit

Permalink
Stop heartbeat thread in case of unhandled exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasst committed Apr 25, 2024
1 parent 8336066 commit e440d8f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tasktiger/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,13 @@ def execute(
heartbeat_thread.start()

# Run the tasks.
result = self.execute_tasks(tasks, log)

# Stop the heartbeat thread.
stop_event.set()
heartbeat_thread.join()
try:
result = self.execute_tasks(tasks, log)
# Always stop the heartbeat thread -- even in case of an unhandled
# exception after running the task code, or when an unhandled
# BaseException is raised from within the task.
finally:
stop_event.set()
heartbeat_thread.join()

return result

0 comments on commit e440d8f

Please sign in to comment.