This commit is contained in:
Timothy Jaeryang Baek 2026-09-09 16:39:44 -04:00
parent 44f9a4f7f9
commit e35b907f73

View file

@ -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.'}