Update web_server.py
This commit is contained in:
parent
ae5582b9a2
commit
8e66a4f692
1 changed files with 9 additions and 3 deletions
|
|
@ -392,8 +392,13 @@ class WebUIDownloadMonitor:
|
|||
# Cancel the stuck download first (like GUI)
|
||||
self._cancel_download_before_retry(task, task_id)
|
||||
|
||||
# Update task for retry
|
||||
with tasks_lock:
|
||||
# Update task for retry with timeout to prevent deadlock
|
||||
lock_acquired = tasks_lock.acquire(timeout=2.0) # 2-second timeout
|
||||
if not lock_acquired:
|
||||
print(f"⚠️ Could not acquire lock for retry {task_id}, will try again next cycle")
|
||||
return
|
||||
|
||||
try:
|
||||
if task_id in download_tasks:
|
||||
task['retry_count'] = task.get('retry_count', 0) + 1
|
||||
if task['retry_count'] > 2: # Max 3 attempts total like GUI
|
||||
|
|
@ -406,7 +411,8 @@ class WebUIDownloadMonitor:
|
|||
task.pop('queued_start_time', None)
|
||||
task.pop('downloading_start_time', None)
|
||||
task['status_change_time'] = time.time()
|
||||
|
||||
finally:
|
||||
tasks_lock.release()
|
||||
# Submit retry to executor
|
||||
missing_download_executor.submit(self._retry_task_with_fallback, batch_id, task_id, task)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue