Only cancel session processor if current generating queue item is cancelled

This commit is contained in:
brandonrising 2024-03-28 14:22:15 -04:00 committed by psychedelicious
parent e8eb9fd533
commit 98cc9b963c

View File

@ -70,8 +70,13 @@ class DefaultSessionProcessor(SessionProcessorBase):
async def _on_queue_event(self, event: FastAPIEvent) -> None:
event_name = event[1]["event"]
if event_name == "session_canceled" or event_name == "queue_cleared":
# These both mean we should cancel the current session.
if event_name == "session_canceled" and self._queue_item\
and self._queue_item.item_id == event[1]["data"]["queue_item_id"]:
self._cancel_event.set()
self._poll_now()
elif event_name == "queue_cleared" and self._queue_item\
and self._queue_item.queue_id == event[1]["data"]["queue_id"]:
self._cancel_event.set()
self._poll_now()
elif event_name == "batch_enqueued":