From e35b907f737e625b900b3a03d61890f67ab0c4b0 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 9 Sep 2026 16:39:44 -0400 Subject: [PATCH] refac --- backend/open_webui/tasks.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/open_webui/tasks.py b/backend/open_webui/tasks.py index 0eb223e9b6..1fe268296e 100644 --- a/backend/open_webui/tasks.py +++ b/backend/open_webui/tasks.py @@ -274,10 +274,10 @@ async def stop_item_tasks(redis: Redis, item_id: str): if not task_ids: return {'status': True, 'message': f'No tasks found for item {item_id}.'} - for task_id in task_ids: - result = await stop_task(redis, task_id) - if not result['status']: - return result # Return the first failure + # Cleanup mutates the local task list while cancellation is awaited. + for task_id in list(task_ids): + # A task that already finished needs no stopping; continue with the rest. + await stop_task(redis, task_id) return {'status': True, 'message': f'All tasks for item {item_id} stopped.'}