Skip to content

Commit 9768476

Browse files
committed
fix: Remove tiled writer if submitted task doesn't exist
Whenever a task is submitted, a TiledWriter is added to the run engine and is only removed when the task is complete. If the task never starts due to not being found, the writer would never be removed and subsequent tasks would have duplicate writers causing write errors to tiled. Catching the KeyError and removing the subscribers immediately is a workaround that works but should be removed when the internal pending tasks queue is removed.
1 parent 774781b commit 9768476

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/blueapi/service/interface.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,12 @@ def remove_callback_when_task_finished(
221221
)
222222

223223
if task.task_id is not None:
224-
active_worker.begin_task(task.task_id)
224+
try:
225+
active_worker.begin_task(task.task_id)
226+
except KeyError:
227+
active_worker.worker_events.unsubscribe(remove_callback)
228+
active_context.run_engine.unsubscribe(tiled_writer_token)
229+
raise
225230
return task
226231

227232

0 commit comments

Comments
 (0)