updated old legacy store names
This commit is contained in:
+9
-10
@@ -2620,6 +2620,7 @@ def download_media(opts: DownloadOptions, *, config: Optional[Dict[str, Any]] =
|
||||
|
||||
|
||||
def _download_with_timeout(opts: DownloadOptions, timeout_seconds: int = 300, config: Optional[Dict[str, Any]] = None) -> Any:
|
||||
from contextvars import copy_context
|
||||
import threading
|
||||
from typing import cast
|
||||
|
||||
@@ -2631,17 +2632,18 @@ def _download_with_timeout(opts: DownloadOptions, timeout_seconds: int = 300, co
|
||||
except Exception as exc:
|
||||
result_container[1] = exc
|
||||
|
||||
# Preserve the active pipeline ContextVar state so yt-dlp progress hooks in the
|
||||
# worker thread can still see the shared Live UI and stage context.
|
||||
download_context = copy_context()
|
||||
|
||||
# Use daemon=True so a hung download doesn't block process exit if the wall timeout hits.
|
||||
thread = threading.Thread(target=_do_download, daemon=True)
|
||||
thread = threading.Thread(target=lambda: download_context.run(_do_download), daemon=True)
|
||||
thread.start()
|
||||
start_time = time.monotonic()
|
||||
|
||||
# We use two timeouts:
|
||||
# 1. Activity timeout (no progress updates for X seconds)
|
||||
# 2. Hard wall-clock timeout (total time for this URL)
|
||||
# The wall-clock timeout is slightly larger than the activity timeout
|
||||
# to allow for slow-but-steady progress, up to a hard cap (e.g. 10 minutes).
|
||||
wall_timeout = max(timeout_seconds * 2, 600)
|
||||
# Keep only an activity timeout here. yt-dlp downloads can be legitimately slow
|
||||
# for large media or constrained connections, and a fixed wall-clock cutoff can
|
||||
# abort healthy downloads even while progress is still arriving.
|
||||
|
||||
_record_progress_activity(start_time)
|
||||
try:
|
||||
@@ -2659,9 +2661,6 @@ def _download_with_timeout(opts: DownloadOptions, timeout_seconds: int = 300, co
|
||||
if now - last_activity > timeout_seconds:
|
||||
raise DownloadError(f"Download activity timeout after {timeout_seconds} seconds for {opts.url}")
|
||||
|
||||
# Check hard wall-clock timeout
|
||||
if now - start_time > wall_timeout:
|
||||
raise DownloadError(f"Download hard timeout after {wall_timeout} seconds for {opts.url}")
|
||||
finally:
|
||||
_clear_progress_activity()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user