mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(queue): fix duplicate queue item status events
This commit is contained in:
parent
098d506b95
commit
183e2c3ee0
@ -77,7 +77,6 @@ class SqliteSessionQueue(SessionQueueBase):
|
|||||||
queue_item = self.get_queue_item(item_id)
|
queue_item = self.get_queue_item(item_id)
|
||||||
if queue_item.status not in ["completed", "failed", "canceled"]:
|
if queue_item.status not in ["completed", "failed", "canceled"]:
|
||||||
queue_item = self._set_queue_item_status(item_id=queue_item.item_id, status="completed")
|
queue_item = self._set_queue_item_status(item_id=queue_item.item_id, status="completed")
|
||||||
self.__invoker.services.events.emit_queue_item_status_changed(queue_item)
|
|
||||||
except SessionQueueItemNotFoundError:
|
except SessionQueueItemNotFoundError:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -86,8 +85,8 @@ class SqliteSessionQueue(SessionQueueBase):
|
|||||||
item_id = event[1]["data"]["queue_item_id"]
|
item_id = event[1]["data"]["queue_item_id"]
|
||||||
error = event[1]["data"]["error"]
|
error = event[1]["data"]["error"]
|
||||||
queue_item = self.get_queue_item(item_id)
|
queue_item = self.get_queue_item(item_id)
|
||||||
|
# always set to failed if have an error, even if previously the item was marked completed or canceled
|
||||||
queue_item = self._set_queue_item_status(item_id=queue_item.item_id, status="failed", error=error)
|
queue_item = self._set_queue_item_status(item_id=queue_item.item_id, status="failed", error=error)
|
||||||
self.__invoker.services.events.emit_queue_item_status_changed(queue_item)
|
|
||||||
except SessionQueueItemNotFoundError:
|
except SessionQueueItemNotFoundError:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -95,8 +94,8 @@ class SqliteSessionQueue(SessionQueueBase):
|
|||||||
try:
|
try:
|
||||||
item_id = event[1]["data"]["queue_item_id"]
|
item_id = event[1]["data"]["queue_item_id"]
|
||||||
queue_item = self.get_queue_item(item_id)
|
queue_item = self.get_queue_item(item_id)
|
||||||
|
if queue_item.status not in ["completed", "failed", "canceled"]:
|
||||||
queue_item = self._set_queue_item_status(item_id=queue_item.item_id, status="canceled")
|
queue_item = self._set_queue_item_status(item_id=queue_item.item_id, status="canceled")
|
||||||
self.__invoker.services.events.emit_queue_item_status_changed(queue_item)
|
|
||||||
except SessionQueueItemNotFoundError:
|
except SessionQueueItemNotFoundError:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -354,7 +353,6 @@ class SqliteSessionQueue(SessionQueueBase):
|
|||||||
return None
|
return None
|
||||||
queue_item = SessionQueueItem.from_dict(dict(result))
|
queue_item = SessionQueueItem.from_dict(dict(result))
|
||||||
queue_item = self._set_queue_item_status(item_id=queue_item.item_id, status="in_progress")
|
queue_item = self._set_queue_item_status(item_id=queue_item.item_id, status="in_progress")
|
||||||
self.__invoker.services.events.emit_queue_item_status_changed(queue_item)
|
|
||||||
return queue_item
|
return queue_item
|
||||||
|
|
||||||
def get_next(self, queue_id: str) -> Optional[SessionQueueItem]:
|
def get_next(self, queue_id: str) -> Optional[SessionQueueItem]:
|
||||||
@ -427,7 +425,9 @@ class SqliteSessionQueue(SessionQueueBase):
|
|||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
self.__lock.release()
|
self.__lock.release()
|
||||||
return self.get_queue_item(item_id)
|
queue_item = self.get_queue_item(item_id)
|
||||||
|
self.__invoker.services.events.emit_queue_item_status_changed(queue_item)
|
||||||
|
return queue_item
|
||||||
|
|
||||||
def is_empty(self, queue_id: str) -> IsEmptyResult:
|
def is_empty(self, queue_id: str) -> IsEmptyResult:
|
||||||
try:
|
try:
|
||||||
@ -565,7 +565,6 @@ class SqliteSessionQueue(SessionQueueBase):
|
|||||||
queue_batch_id=queue_item.batch_id,
|
queue_batch_id=queue_item.batch_id,
|
||||||
graph_execution_state_id=queue_item.session_id,
|
graph_execution_state_id=queue_item.session_id,
|
||||||
)
|
)
|
||||||
self.__invoker.services.events.emit_queue_item_status_changed(queue_item)
|
|
||||||
return queue_item
|
return queue_item
|
||||||
|
|
||||||
def cancel_by_batch_ids(self, queue_id: str, batch_ids: list[str]) -> CancelByBatchIDsResult:
|
def cancel_by_batch_ids(self, queue_id: str, batch_ids: list[str]) -> CancelByBatchIDsResult:
|
||||||
|
Loading…
Reference in New Issue
Block a user