mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2025-12-19 11:23:00 +08:00
refresh cache before reporting status
This commit is contained in:
parent
b55e1404b1
commit
b73dc6121f
@ -289,7 +289,7 @@ class TaskQueue:
|
|||||||
)
|
)
|
||||||
return item, task_index
|
return item, task_index
|
||||||
|
|
||||||
def task_done(
|
async def task_done(
|
||||||
self,
|
self,
|
||||||
item: QueueTaskItem,
|
item: QueueTaskItem,
|
||||||
task_index: int,
|
task_index: int,
|
||||||
@ -327,19 +327,29 @@ class TaskQueue:
|
|||||||
status=pydantic_status,
|
status=pydantic_status,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Send WebSocket message indicating task is complete
|
# Force cache refresh for successful pack-modifying operations
|
||||||
TaskQueue.send_queue_state_update(
|
pack_modifying_tasks = {"install", "uninstall", "enable", "disable"}
|
||||||
ManagerMessageName.cm_task_completed.value,
|
if (item.kind in pack_modifying_tasks and
|
||||||
MessageTaskDone(
|
status and status.status_str == "success"):
|
||||||
ui_id=item.ui_id,
|
try:
|
||||||
result=result_msg,
|
# Force unified_manager to refresh its installed packages cache
|
||||||
kind=item.kind,
|
await core.unified_manager.reload("cache", dont_wait=True, update_cnr_map=False)
|
||||||
status=pydantic_status,
|
except Exception as e:
|
||||||
timestamp=datetime.fromisoformat(timestamp),
|
logging.warning(f"[ComfyUI-Manager] Failed to refresh cache after {item.kind}: {e}")
|
||||||
state=self.get_current_state(),
|
|
||||||
),
|
# Send WebSocket message indicating task is complete
|
||||||
client_id=item.client_id, # Send completion only to the client that requested it
|
TaskQueue.send_queue_state_update(
|
||||||
)
|
ManagerMessageName.cm_task_completed.value,
|
||||||
|
MessageTaskDone(
|
||||||
|
ui_id=item.ui_id,
|
||||||
|
result=result_msg,
|
||||||
|
kind=item.kind,
|
||||||
|
status=pydantic_status,
|
||||||
|
timestamp=datetime.fromisoformat(timestamp),
|
||||||
|
state=self.get_current_state(),
|
||||||
|
),
|
||||||
|
client_id=item.client_id, # Send completion only to the client that requested it
|
||||||
|
)
|
||||||
|
|
||||||
def get_current_queue(self) -> tuple[list[QueueTaskItem], list[QueueTaskItem]]:
|
def get_current_queue(self) -> tuple[list[QueueTaskItem], list[QueueTaskItem]]:
|
||||||
"""Get current running and remaining tasks"""
|
"""Get current running and remaining tasks"""
|
||||||
@ -858,7 +868,7 @@ async def task_worker():
|
|||||||
msg = "Unexpected kind: " + kind
|
msg = "Unexpected kind: " + kind
|
||||||
except Exception:
|
except Exception:
|
||||||
msg = f"Exception: {(kind, item)}"
|
msg = f"Exception: {(kind, item)}"
|
||||||
task_queue.task_done(
|
await task_queue.task_done(
|
||||||
item, task_index, msg, TaskQueue.ExecutionStatus("error", True, [msg])
|
item, task_index, msg, TaskQueue.ExecutionStatus("error", True, [msg])
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@ -877,7 +887,7 @@ async def task_worker():
|
|||||||
else:
|
else:
|
||||||
status = TaskQueue.ExecutionStatus("error", True, [result_msg])
|
status = TaskQueue.ExecutionStatus("error", True, [result_msg])
|
||||||
|
|
||||||
task_queue.task_done(item, task_index, result_msg, status)
|
await task_queue.task_done(item, task_index, result_msg, status)
|
||||||
|
|
||||||
|
|
||||||
@routes.post("/v2/manager/queue/task")
|
@routes.post("/v2/manager/queue/task")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user