Fix _meta_run: hold lock for entire yt-dlp execution, not just scheduling
Previously the lock was released before _run(), so multiple threads could fire yt-dlp processes simultaneously — completely defeating the rate limiter. Now the lock is held through the subprocess call and released in finally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -33,8 +33,10 @@ def _meta_run(args: list[str], timeout: int = 60) -> tuple[str, str, int]:
|
|||||||
wait = _META_MIN_GAP - (now - _meta_last_call)
|
wait = _META_MIN_GAP - (now - _meta_last_call)
|
||||||
if wait > 0:
|
if wait > 0:
|
||||||
time.sleep(wait + random.uniform(0.5, 2.5))
|
time.sleep(wait + random.uniform(0.5, 2.5))
|
||||||
_meta_last_call = time.monotonic()
|
try:
|
||||||
return _run(args, timeout=timeout)
|
return _run(args, timeout=timeout)
|
||||||
|
finally:
|
||||||
|
_meta_last_call = time.monotonic()
|
||||||
|
|
||||||
|
|
||||||
def _parse_date(date_str: str | None) -> datetime | None:
|
def _parse_date(date_str: str | None) -> datetime | None:
|
||||||
|
|||||||
Reference in New Issue
Block a user