[object Object]

← back to Exo

check if we have a task before we delete it (#1634)

d914acd64eb72b6db50c46cbde533fb9c1b6a4f2 · 2026-03-03 15:32:12 +0000 · Evan Quiney

caused a crash we should instead be logging

Files touched

Diff

commit d914acd64eb72b6db50c46cbde533fb9c1b6a4f2
Author: Evan Quiney <evanev7@gmail.com>
Date:   Tue Mar 3 15:32:12 2026 +0000

    check if we have a task before we delete it (#1634)
    
    caused a crash we should instead be logging
---
 src/exo/master/main.py | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/exo/master/main.py b/src/exo/master/main.py
index fe981046..b316f64d 100644
--- a/src/exo/master/main.py
+++ b/src/exo/master/main.py
@@ -328,17 +328,22 @@ class Master:
                                         task_id=task_id,
                                     )
                                 )
+                            else:
+                                logger.warning(
+                                    f"Nonexistent command {command.cancelled_command_id} cancelled"
+                                )
                         case TaskFinished():
-                            generated_events.append(
-                                TaskDeleted(
-                                    task_id=self.command_task_mapping[
-                                        command.finished_command_id
-                                    ]
+                            if (
+                                task_id := self.command_task_mapping.pop(
+                                    command.finished_command_id, None
                                 )
-                            )
-                            self.command_task_mapping.pop(
-                                command.finished_command_id, None
-                            )
+                            ) is not None:
+                                generated_events.append(TaskDeleted(task_id=task_id))
+                            else:
+                                logger.warning(
+                                    f"Finished command {command.finished_command_id} finished"
+                                )
+
                         case RequestEventLog():
                             # We should just be able to send everything, since other buffers will ignore old messages
                             # rate limit to 1000 at a time

← 37296c82 Refactor runner for implementing batching (#1632)  ·  back to Exo  ·  ignore closed resource errors when trying to cancel a task ( 886192f1 →