Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
XianxinMao
Yt Dlp
提交
059bc4db
Y
Yt Dlp
项目概览
XianxinMao
/
Yt Dlp
12 个月 前同步成功
通知
27
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
Yt Dlp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
059bc4db
编写于
4月 26, 2022
作者:
P
pukkandan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[compat/asyncio] Use `asyncio.all_tasks`
上级
9196cbfe
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
11 addition
and
20 deletion
+11
-20
Makefile
Makefile
+1
-1
yt_dlp/compat/asyncio.py
yt_dlp/compat/asyncio.py
+6
-2
yt_dlp/compat/asyncio/tasks.py
yt_dlp/compat/asyncio/tasks.py
+0
-13
yt_dlp/utils.py
yt_dlp/utils.py
+4
-4
未找到文件。
Makefile
浏览文件 @
059bc4db
...
...
@@ -66,7 +66,7 @@ offlinetest: codetest
# XXX: This is hard to maintain
CODE_FOLDERS
=
yt_dlp yt_dlp/downloader yt_dlp/extractor yt_dlp/postprocessor yt_dlp/compat
\
yt_dlp/
compat/asyncio yt_dlp/
extractor/anvato_token_generator
yt_dlp/extractor/anvato_token_generator
yt-dlp
:
yt_dlp/*.py yt_dlp/*/*.py
mkdir
-p
zip
for
d
in
$(CODE_FOLDERS)
;
do
\
...
...
yt_dlp/compat/asyncio
/__init__
.py
→
yt_dlp/compat/asyncio.py
浏览文件 @
059bc4db
...
...
@@ -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 @@ def run(coro):
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
yt_dlp/compat/asyncio/tasks.py
已删除
100644 → 0
浏览文件 @
9196cbfe
# 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
yt_dlp/utils.py
浏览文件 @
059bc4db
...
...
@@ -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 @@ def __exit__(self, type, value, traceback):
# 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 @@ def run_with_loop(main, loop):
@
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 @@ def _cancel_all_tasks(loop):
# 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
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录