Skip to content

Commit 4251eaf

Browse files
committed
fix: make task cancellation non-blocking consistent with Redis fire-and-forget pattern
1 parent 0538c3b commit 4251eaf

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

backend/open_webui/tasks.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,8 @@ async def stop_task(redis, task_id: str):
155155
if not task:
156156
return {"status": False, "message": f"Task with ID {task_id} not found."}
157157

158-
task.cancel() # Request task cancellation
159-
try:
160-
await task # Wait for the task to handle the cancellation
161-
except asyncio.CancelledError:
162-
# Task successfully canceled
163-
return {"status": True, "message": f"Task {task_id} successfully stopped."}
164-
165-
if task.cancelled() or task.done():
166-
return {"status": True, "message": f"Task {task_id} successfully cancelled."}
167-
168-
return {"status": True, "message": f"Cancellation requested for {task_id}."}
158+
task.cancel()
159+
return {"status": True, "message": f"Task {task_id} cancellation requested."}
169160

170161

171162
async def stop_item_tasks(redis: Redis, item_id: str):

0 commit comments

Comments
 (0)