Skip to content

Commit

Permalink
fix: enhance task cancellation logic to prevent errors on closed tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
elikoga committed Jan 20, 2025
1 parent 2689a1f commit d97ae5d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion controller/thymis_controller/task/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ def cancel_task(self, task_id: uuid.UUID):
def cancel_all_tasks(self):
future_tasks = list(self.futures.keys())
for task_id in future_tasks:
if task_id in self.futures and self.futures[task_id][0].running():
if (
task_id in self.futures
and self.futures[task_id][0].running()
and not self.futures[task_id][1].closed
):
self.cancel_task(task_id)

def listen_child_messages(self, conn: Connection, task_id: uuid.UUID):
Expand Down

0 comments on commit d97ae5d

Please sign in to comment.