[compat/asyncio] Use asyncio.all_tasks
This commit is contained in:
parent
9196cbfe8b
commit
059bc4db19
4 changed files with 11 additions and 20 deletions
24
yt_dlp/compat/asyncio.py
Normal file
24
yt_dlp/compat/asyncio.py
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue