Description
In app/services/download_manager.py, the download_video function iterates over process.stdout in a synchronous for loop before calling process.wait(timeout=3600).
for line in process.stdout or []:
last_line = line
...
process.wait(timeout=3600)
Impact
If yt-dlp hangs and stops emitting output without closing stdout (e.g., due to network stall), the for line in process.stdout loop will block indefinitely. The 3600s timeout on process.wait() will never be triggered because it only executes after the stdout loop finishes. This leads to a deadlock where the celery worker gets permanently stuck.
Suggested Fix
Use asynchronous reading for stdout, or use subprocess.run with a timeout and a background thread, or check elapsed time inside the loop with non-blocking reads.
Description
In
app/services/download_manager.py, thedownload_videofunction iterates overprocess.stdoutin a synchronousforloop before callingprocess.wait(timeout=3600).Impact
If
yt-dlphangs and stops emitting output without closingstdout(e.g., due to network stall), thefor line in process.stdoutloop will block indefinitely. The 3600s timeout onprocess.wait()will never be triggered because it only executes after the stdout loop finishes. This leads to a deadlock where the celery worker gets permanently stuck.Suggested Fix
Use asynchronous reading for
stdout, or usesubprocess.runwith atimeoutand a background thread, or check elapsed time inside the loop with non-blocking reads.