From a6be26e17447571c81f267374a3945a12b2e72ca Mon Sep 17 00:00:00 2001 From: Mary Hipp Date: Mon, 2 Dec 2024 09:00:37 -0500 Subject: [PATCH] fix(worker): only apply processor cancel logic if cancel event is for current queue item --- .../services/session_processor/session_processor_default.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/invokeai/app/services/session_processor/session_processor_default.py b/invokeai/app/services/session_processor/session_processor_default.py index e4faaeb9113..807cadaceda 100644 --- a/invokeai/app/services/session_processor/session_processor_default.py +++ b/invokeai/app/services/session_processor/session_processor_default.py @@ -378,6 +378,9 @@ async def _on_batch_enqueued(self, event: FastAPIEvent[BatchEnqueuedEvent]) -> N self._poll_now() async def _on_queue_item_status_changed(self, event: FastAPIEvent[QueueItemStatusChangedEvent]) -> None: + # Make sure the cancel event is for the currently processing queue item + if self._queue_item and self._queue_item.item_id is not event[1].item_id: + return if self._queue_item and event[1].status in ["completed", "failed", "canceled"]: # When the queue item is canceled via HTTP, the queue item status is set to `"canceled"` and this event is # emitted. We need to respond to this event and stop graph execution. This is done by setting the cancel