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

WebsocketWrapper deprecation warning: remove loop argument #8439

Closed
9 of 10 tasks
aman207 opened this issue Oct 26, 2023 · 1 comment · Fixed by #7720
Closed
9 of 10 tasks

WebsocketWrapper deprecation warning: remove loop argument #8439

aman207 opened this issue Oct 26, 2023 · 1 comment · Fixed by #7720
Labels
bug Bug that is not site-specific site-bug Issue with a specific website

Comments

@aman207
Copy link

aman207 commented Oct 26, 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

  • I'm reporting a bug unrelated to a specific site
  • I've verified that I'm running yt-dlp version 2023.10.13 (update instructions) or later (specify commit)
  • I've checked that all provided URLs are playable in a browser with the same IP and same login details
  • I've checked that all URLs and arguments with special characters are properly quoted or escaped
  • I've searched known issues and the bugtracker for similar issues including closed ones. DO NOT post duplicates
  • I've read the guidelines for opening an issue

Provide a description that is worded well enough to be understood

When running any extractor that uses WebsocketWrapper, the following deprecation warning appears regarding the loop parameter in websockets.connect

ERROR: remove loop argument
Traceback (most recent call last):
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/YoutubeDL.py", line 1567, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/YoutubeDL.py", line 1702, in __extract_info
    ie_result = ie.extract(url)
                ^^^^^^^^^^^^^^^
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/extractor/common.py", line 715, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/extractor/niconico.py", line 958, in _real_extract
    ws = WebSocketsWrapper(ws_url, {
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/utils/_utils.py", line 4933, in __init__
    self.conn = websockets.connect(
                ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/websockets/legacy/client.py", line 488, in __init__
    warnings.warn("remove loop argument", DeprecationWarning)
DeprecationWarning: remove loop argument

Although the warning can be suppressed, this problem should still be resolved

If the loop parameter is removed from websockets.connect, another error appears

Traceback (most recent call last):
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/YoutubeDL.py", line 1567, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/YoutubeDL.py", line 1702, in __extract_info
    ie_result = ie.extract(url)
                ^^^^^^^^^^^^^^^
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/extractor/common.py", line 715, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/extractor/niconico.py", line 958, in _real_extract
    ws = WebSocketsWrapper(ws_url, {
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/utils/_utils.py", line 4937, in __init__
    self.__enter__()
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/utils/_utils.py", line 4942, in __enter__
    self.pool = self.run_with_loop(self.conn.__aenter__(), self.loop)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/utils/_utils.py", line 4966, in run_with_loop
    return loop.run_until_complete(main)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/websockets/legacy/client.py", line 642, in __aenter__
    return await self
           ^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/websockets/legacy/client.py", line 659, in __await_impl_timeout__
    return await asyncio.wait_for(self.__await_impl__(), self.open_timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/websockets/legacy/client.py", line 663, in __await_impl__
    _transport, _protocol = await self._create_connection()
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 1045, in create_connection
    infos = await self._ensure_resolved(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 1419, in _ensure_resolved
    return await loop.getaddrinfo(host, port, family=family, type=type,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 867, in getaddrinfo
    return await self.run_in_executor(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: ... attached to a different loop

I'm far from being an expert with async stuff so I'm not sure where to go from here.

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

[onionadmin@emby yt-dlp]$ ./yt-dlp.sh https://live2.nicovideo.jp/watch/lv343173227?ref=nicotop_stage -vU
[debug] Command-line config: ['https://live2.nicovideo.jp/watch/lv343173227?ref=nicotop_stage', '-vU']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2023.10.13 [b634ba742] (source)
[debug] Lazy loading extractors is disabled
[debug] Git HEAD: 9683b820b
[debug] Python 3.11.5 (CPython x86_64 64bit) - Linux-6.2.16-12-pve-x86_64-with-glibc2.38 (OpenSSL 3.1.4 24 Oct 2023, glibc 2.38)
[debug] exe versions: ffmpeg 6.0 (setts), ffprobe 6.0
[debug] Optional libraries: Cryptodome-3.12.0, brotli-1.1.0, certifi-2023.07.22, mutagen-1.47.0, requests-2.31.0, sqlite3-3.43.2, urllib3-1.26.15, websockets-10.4
[debug] Proxy map: {}
[debug] Request Handlers: urllib
[debug] Loaded 1891 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Available version: stable@2023.10.13, Current version: stable@2023.10.13
yt-dlp is up to date (stable@2023.10.13)
[niconico:live] Extracting URL: https://live2.nicovideo.jp/watch/lv343173227?ref=nicotop_stage
[niconico:live] lv343173227: Downloading webpage
ERROR: "YoutubeDL._calc_cookies" is deprecated and may be removed in a future version; please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/__main__.py", line 17, in <module>
    yt_dlp.main()
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/__init__.py", line 1008, in main
    _exit(*variadic(_real_main(argv)))
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/__init__.py", line 998, in _real_main
    return ydl.download(all_urls)
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/YoutubeDL.py", line 3510, in download
    self.__download_wrapper(self.extract_info)(
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/YoutubeDL.py", line 3485, in wrapper
    res = func(*args, **kwargs)
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/YoutubeDL.py", line 1556, in extract_info
    return self.__extract_info(url, self.get_info_extractor(key), download, extra_info, process)
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/YoutubeDL.py", line 1567, in wrapper
    return func(self, *args, **kwargs)
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/YoutubeDL.py", line 1702, in __extract_info
    ie_result = ie.extract(url)
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/extractor/common.py", line 715, in extract
    ie_result = self._real_extract(url)
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/extractor/niconico.py", line 953, in _real_extract
    cookies = try_get(urlh.url, self._downloader._calc_cookies)
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/utils/_utils.py", line 2613, in try_get
    return try_call(*variadic(getter), args=(src,), expected_type=expected_type)
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/utils/_utils.py", line 2604, in try_call
    val = f(*args, **kwargs)
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/YoutubeDL.py", line 2520, in _calc_cookies
    self.deprecation_warning('"YoutubeDL._calc_cookies" is deprecated and may be removed in a future version')
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/YoutubeDL.py", line 1032, in deprecation_warning
    deprecation_warning(
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/utils/_utils.py", line 1447, in deprecation_warning
    return printer(f'{msg}{bug_reports_message()}', **kwargs)
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/YoutubeDL.py", line 1045, in report_error
    self.trouble(f'{self._format_err("ERROR:", self.Styles.ERROR)} {message}', *args, **kwargs)
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/YoutubeDL.py", line 973, in trouble
    tb_data = traceback.format_list(traceback.extract_stack())

ERROR: remove loop argument
Traceback (most recent call last):
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/YoutubeDL.py", line 1567, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/YoutubeDL.py", line 1702, in __extract_info
    ie_result = ie.extract(url)
                ^^^^^^^^^^^^^^^
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/extractor/common.py", line 715, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/extractor/niconico.py", line 958, in _real_extract
    ws = WebSocketsWrapper(ws_url, {
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/onionadmin/python/patreon/yt-dlp/yt_dlp/utils/_utils.py", line 4933, in __init__
    self.conn = websockets.connect(
                ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/websockets/legacy/client.py", line 488, in __init__
    warnings.warn("remove loop argument", DeprecationWarning)
DeprecationWarning: remove loop argument

Exception ignored in: <function BaseEventLoop.__del__ at 0x7f98579d9700>
Traceback (most recent call last):
  File "/usr/lib/python3.11/asyncio/base_events.py", line 692, in __del__
    _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=True>
Exception ignored in: <socket.socket fd=4, family=1, type=1, proto=0>
ResourceWarning: unclosed <socket.socket fd=4, family=1, type=1, proto=0>
Exception ignored in: <socket.socket fd=5, family=1, type=1, proto=0>
ResourceWarning: unclosed <socket.socket fd=5, family=1, type=1, proto=0>
@aman207 aman207 added bug Bug that is not site-specific triage Untriaged issue labels Oct 26, 2023
@coletdjnz
Copy link
Member

coletdjnz commented Oct 26, 2023

Will be fixed by #7720

@coletdjnz coletdjnz added site-bug Issue with a specific website and removed triage Untriaged issue labels Oct 26, 2023
@bashonly bashonly linked a pull request Oct 26, 2023 that will close this issue
9 tasks
coletdjnz added a commit that referenced this issue Nov 20, 2023
* Adds a basic WebSocket framework
* Introduces new minimum `websockets` version of 12.0
* Deprecates `WebSocketsWrapper`

Fixes #8439

Authored by: coletdjnz
aalsuwaidi pushed a commit to aalsuwaidi/yt-dlp that referenced this issue Apr 21, 2024
* Adds a basic WebSocket framework
* Introduces new minimum `websockets` version of 12.0
* Deprecates `WebSocketsWrapper`

Fixes yt-dlp#8439

Authored by: coletdjnz
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 site-bug Issue with a specific website
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants