aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/utils.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-04-26 05:35:06 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-04-26 05:43:19 +0530
commit9cd080508db2daf625994f9aef29790f4bca7996 (patch)
treecf2235b0242f8c3ad34a9712712055ad51902fc3 /yt_dlp/utils.py
parent69b59b4b4b52e496df980d8d21ad5ff670089c0b (diff)
downloadhypervideo-pre-9cd080508db2daf625994f9aef29790f4bca7996.tar.lz
hypervideo-pre-9cd080508db2daf625994f9aef29790f4bca7996.tar.xz
hypervideo-pre-9cd080508db2daf625994f9aef29790f4bca7996.zip
Revert acbc64225006964cf52d316e007a77a1b5e2975b
Reverts "[utils] WebSocketsWrapper: Ignore warnings at websockets instantiation" The warning should not be suppressed. We need to address it
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r--yt_dlp/utils.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index 844b9cb19..90f070b6d 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -36,7 +36,6 @@ import tempfile
import time
import traceback
import urllib.parse
-import warnings
import xml.etree.ElementTree
import zlib
@@ -5222,23 +5221,18 @@ class WebSocketsWrapper():
pool = None
def __init__(self, url, headers=None, connect=True):
- self.loop = asyncio.new_event_loop()
- with warnings.catch_warnings():
- warnings.simplefilter("ignore")
- # https://github.com/aaugustin/websockets/blob/9c87d43f1d7bbf6847350087aae74fd35f73a642/src/websockets/legacy/client.py#L480
- # the reason to keep giving `loop` parameter: we aren't in async function
- self.conn = websockets.connect(
- url, extra_headers=headers, ping_interval=None,
- close_timeout=float('inf'), loop=self.loop, ping_timeout=float('inf'))
+ self.loop = asyncio.events.new_event_loop()
+ # XXX: "loop" is deprecated
+ self.conn = websockets.connect(
+ url, extra_headers=headers, ping_interval=None,
+ close_timeout=float('inf'), loop=self.loop, ping_timeout=float('inf'))
if connect:
self.__enter__()
atexit.register(self.__exit__, None, None, None)
def __enter__(self):
if not self.pool:
- with warnings.catch_warnings():
- warnings.simplefilter("ignore")
- self.pool = self.run_with_loop(self.conn.__aenter__(), self.loop)
+ self.pool = self.run_with_loop(self.conn.__aenter__(), self.loop)
return self
def send(self, *args):
@@ -5258,7 +5252,7 @@ class WebSocketsWrapper():
# for contributors: If there's any new library using asyncio needs to be run in non-async, move these function out of this class
@staticmethod
def run_with_loop(main, loop):
- if not asyncio.iscoroutine(main):
+ if not asyncio.coroutines.iscoroutine(main):
raise ValueError(f'a coroutine was expected, got {main!r}')
try:
@@ -5278,6 +5272,7 @@ class WebSocketsWrapper():
for task in to_cancel:
task.cancel()
+ # XXX: "loop" is removed in python 3.10+
loop.run_until_complete(
asyncio.tasks.gather(*to_cancel, loop=loop, return_exceptions=True))