Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check-formats hang with NON-writable working directory #7894

Open
10 of 11 tasks
alervd opened this issue Aug 18, 2023 · 5 comments
Open
10 of 11 tasks

check-formats hang with NON-writable working directory #7894

alervd opened this issue Aug 18, 2023 · 5 comments
Labels
bug Bug that is not site-specific external issue Issue with an external tool

Comments

@alervd
Copy link

alervd commented Aug 18, 2023

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I intentionally remove or skip any mandatory* field

Checklist

Region

No response

Provide a description that is worded well enough to be understood

In case the working directory is NOT writable (IMPORTANT!), e.g. C:\Program Files, yt-dlp stuck when trying to just parse particular video URL (using -J parameter). Not all URLs are affected. It seems the ones with DRM.
Yt-dlp never finishes. Python process is stuck consuming 50MB of memory and 50% of CPU core.

Issue is NOT reproducible in the previous 2023.06.22 release.

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • If using API, add 'verbose': True to YoutubeDL params instead
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

[debug] Command-line config: ['-vU', '-J', 'https://www.youtube.com/watch?v=kkUIdK9eaIk']
[debug] Encodings: locale cp1251, fs utf-8, pref cp1251, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2023.07.06 [b532a3481] (source)
[debug] Lazy loading extractors is disabled
[debug] Git HEAD: 876b70c8e
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.19043-SP0 (OpenSSL 1.1.1k  25 Mar 2021)
[debug] exe versions: none
[debug] Optional libraries: Cryptodome-3.14.1, brotli-1.0.9, mutagen-1.45.1, sqlite3-2.6.0, websockets-10.2
[debug] Proxy map: {}
[debug] Loaded 1863 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Available version: stable@2023.07.06, Current version: stable@2023.07.06
yt-dlp is up to date (stable@2023.07.06)
[youtube] Extracting URL: https://www.youtube.com/watch?v=kkUIdK9eaIk
[youtube] kkUIdK9eaIk: Downloading webpage
[youtube] kkUIdK9eaIk: Downloading ios player API JSON
[youtube] kkUIdK9eaIk: Downloading android player API JSON
[youtube] kkUIdK9eaIk: Downloading m3u8 information
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), channels, acodec, lang, proto, size, br, asr, vext, aext, hasaud, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] Testing format 616
@alervd alervd added site-bug Issue with a specific website triage Untriaged issue labels Aug 18, 2023
@bashonly bashonly added bug Bug that is not site-specific and removed site-bug Issue with a specific website labels Aug 18, 2023
@pukkandan
Copy link
Member

Testing format currently requires writing a temp file. I don't know why it gets stuck instead of throwing an error though. As workaround, ask yt-dlp to write temp files to different directory -P temp:C:\temp

@alervd
Copy link
Author

alervd commented Aug 20, 2023

Testing format currently requires writing a temp file. I don't know why it gets stuck instead of throwing an error though. As workaround, ask yt-dlp to write temp files to different directory -P temp:C:\temp

Can it be Python bug? I was using Process Explorer to see the stack trace - it was stuck inside of Py_gitversion. Weird....

@gamer191 gamer191 added the regression Works in youtube-dl/older yt-dlp label Aug 22, 2023
@coletdjnz coletdjnz added external issue Issue with an external tool core-triage triage requested from a core dev and removed triage Untriaged issue regression Works in youtube-dl/older yt-dlp labels Sep 18, 2023
@coletdjnz
Copy link
Member

This is indeed likely a Python bug - an old one that is.

It's an issue with tempfile where it hangs if the directory is not writeable on Windows.

We have used tempfile for file --check-formats downloads into for a while, introduced by 21cd8fa

python/cpython#66305
https://stackoverflow.com/questions/55109076/python-tempfile-temporaryfile-hangs-on-windows-when-no-write-privilege

@coletdjnz coletdjnz removed the core-triage triage requested from a core dev label Sep 18, 2023
@coletdjnz coletdjnz changed the title Stuck at "Testing format 616" stage when trying to parse video in NON-writable working directory check-formats hang with NON-writable working directory Sep 18, 2023
@Kadigan
Copy link

Kadigan commented Nov 20, 2023

Would it be possible to work around this by finding out what the temp path is (what tempfile.TemporaryFile wants to open), check write permissions on that path, and throw up a warning + disable the check if write permissions don't exist?

Alternatively, could a different approach be used to achieve the same functionality? Assuming nobody else has resolved the issue in their solution, that is.

It may be a Python bug, but if it's been up on SO for nearly 5 years - perhaps we shouldn't expect an upstream resolution any time soon.

@TheRealQuantam
Copy link

I'll just leave this here, in case anybody needs a working workaround for this till it gets fixed. python/cpython#66305 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that is not site-specific external issue Issue with an external tool
Projects
None yet
Development

No branches or pull requests

7 participants