aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-04-26 05:45:18 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-04-26 05:45:18 +0530
commit059bc4db1975698dca53278a0fcc23d428b7658a (patch)
treea0489cad76d8a401647263f2c000b16fe48777e1 /yt_dlp
parent9196cbfe8bb7a6eb46037735b76f21963dfdc61a (diff)
downloadhypervideo-pre-059bc4db1975698dca53278a0fcc23d428b7658a.tar.lz
hypervideo-pre-059bc4db1975698dca53278a0fcc23d428b7658a.tar.xz
hypervideo-pre-059bc4db1975698dca53278a0fcc23d428b7658a.zip
[compat/asyncio] Use `asyncio.all_tasks`
Diffstat (limited to 'yt_dlp')
-rw-r--r--yt_dlp/compat/asyncio.py (renamed from yt_dlp/compat/asyncio/__init__.py)8
-rw-r--r--yt_dlp/compat/asyncio/tasks.py13
-rw-r--r--yt_dlp/utils.py8
3 files changed, 10 insertions, 19 deletions
diff --git a/yt_dlp/compat/asyncio/__init__.py b/yt_dlp/compat/asyncio.py
index 21b494499..f80dc192d 100644
--- a/yt_dlp/compat/asyncio/__init__.py
+++ b/yt_dlp/compat/asyncio.py
@@ -2,8 +2,7 @@
from asyncio import * # noqa: F403
-from . import tasks # noqa: F401
-from ..compat_utils import passthrough_module
+from .compat_utils import passthrough_module
passthrough_module(__name__, 'asyncio')
del passthrough_module
@@ -18,3 +17,8 @@ except NameError:
loop = new_event_loop()
set_event_loop(loop)
loop.run_until_complete(coro)
+
+try:
+ all_tasks # >= 3.7
+except NameError:
+ all_tasks = Task.all_tasks
diff --git a/yt_dlp/compat/asyncio/tasks.py b/yt_dlp/compat/asyncio/tasks.py
deleted file mode 100644
index 9d98fdfeb..000000000
--- a/yt_dlp/compat/asyncio/tasks.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# flake8: noqa: F405
-
-from asyncio.tasks import * # noqa: F403
-
-from ..compat_utils import passthrough_module
-
-passthrough_module(__name__, 'asyncio.tasks')
-del passthrough_module
-
-try: # >= 3.7
- all_tasks
-except NameError:
- all_tasks = Task.all_tasks
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index 90f070b6d..0171394fc 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -5221,7 +5221,7 @@ class WebSocketsWrapper():
pool = None
def __init__(self, url, headers=None, connect=True):
- self.loop = asyncio.events.new_event_loop()
+ self.loop = asyncio.new_event_loop()
# XXX: "loop" is deprecated
self.conn = websockets.connect(
url, extra_headers=headers, ping_interval=None,
@@ -5252,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.coroutines.iscoroutine(main):
+ if not asyncio.iscoroutine(main):
raise ValueError(f'a coroutine was expected, got {main!r}')
try:
@@ -5264,7 +5264,7 @@ class WebSocketsWrapper():
@staticmethod
def _cancel_all_tasks(loop):
- to_cancel = asyncio.tasks.all_tasks(loop)
+ to_cancel = asyncio.all_tasks(loop)
if not to_cancel:
return
@@ -5274,7 +5274,7 @@ class WebSocketsWrapper():
# XXX: "loop" is removed in python 3.10+
loop.run_until_complete(
- asyncio.tasks.gather(*to_cancel, loop=loop, return_exceptions=True))
+ asyncio.gather(*to_cancel, loop=loop, return_exceptions=True))
for task in to_cancel:
if task.cancelled():