Browse Source

fix: fix error when stopping non-existent task

Shirasawa 1 tháng trước cách đây
mục cha
commit
e5ea595425
1 tập tin đã thay đổi với 2 bổ sung2 xóa
  1. 2 2
      backend/open_webui/tasks.py

+ 2 - 2
backend/open_webui/tasks.py

@@ -153,9 +153,9 @@ async def stop_task(redis, task_id: str):
         # Optionally check if task_id still in Redis a few moments later for feedback?
         return {"status": True, "message": f"Stop signal sent for {task_id}"}
 
-    task = tasks.pop(task_id)
+    task = tasks.pop(task_id, None)
     if not task:
-        raise ValueError(f"Task with ID {task_id} not found.")
+        return {"status": False, "message": f"Task with ID {task_id} not found."}
 
     task.cancel()  # Request task cancellation
     try: