Skip to content

Bug: Subprocess Deadlock in yt-dlp Download Wrapper #31

@windoze95

Description

@windoze95

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions