diff options
Diffstat (limited to 'yt_dlp/compat/asyncio')
-rw-r--r-- | yt_dlp/compat/asyncio/__init__.py | 16 | ||||
-rw-r--r-- | yt_dlp/compat/asyncio/tasks.py | 8 |
2 files changed, 24 insertions, 0 deletions
diff --git a/yt_dlp/compat/asyncio/__init__.py b/yt_dlp/compat/asyncio/__init__.py new file mode 100644 index 000000000..0e8c6cad3 --- /dev/null +++ b/yt_dlp/compat/asyncio/__init__.py @@ -0,0 +1,16 @@ +# flake8: noqa: F405 + +from asyncio import * # noqa: F403 + +from . import tasks # noqa: F401 + +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) diff --git a/yt_dlp/compat/asyncio/tasks.py b/yt_dlp/compat/asyncio/tasks.py new file mode 100644 index 000000000..cb31e52fa --- /dev/null +++ b/yt_dlp/compat/asyncio/tasks.py @@ -0,0 +1,8 @@ +# flake8: noqa: F405 + +from asyncio.tasks import * # noqa: F403 + +try: # >= 3.7 + all_tasks +except NameError: + all_tasks = Task.all_tasks |