Skip to content

Commit

Permalink
fix: improve task cancellation logic to avoid errors on already compl…
Browse files Browse the repository at this point in the history
…eted tasks
  • Loading branch information
elikoga committed Jan 20, 2025
1 parent ae05b20 commit 2689a1f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions controller/thymis_controller/task/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ def cancel_task(self, task_id: uuid.UUID):
self.futures[task_id][1].send(models_task.CancelTask(id=task_id))

def cancel_all_tasks(self):
for task_id in self.futures:
self.cancel_task(task_id)
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():
self.cancel_task(task_id)

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

0 comments on commit 2689a1f

Please sign in to comment.