aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/compat/asyncio.py
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/compat/asyncio.py
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/compat/asyncio.py')
-rw-r--r--yt_dlp/compat/asyncio.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/yt_dlp/compat/asyncio.py b/yt_dlp/compat/asyncio.py
new file mode 100644
index 000000000..f80dc192d
--- /dev/null
+++ b/yt_dlp/compat/asyncio.py
@@ -0,0 +1,24 @@
+# flake8: noqa: F405
+
+from asyncio import * # noqa: F403
+
+from .compat_utils import passthrough_module
+
+passthrough_module(__name__, 'asyncio')
+del passthrough_module
+
+try:
+ run # >= 3.7
+except NameError:
+ def run(coro):
+ try:
+ loop = get_event_loop()
+ except RuntimeError:
+ 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