Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
845212af
Commit
845212af
authored
Jul 16, 2014
by
Victor Stinner
Browse files
Options
Browse Files
Download
Plain Diff
(Merge 3.4) Issue #21163, asyncio: Ignore "destroy pending task" warnings for
private tasks in gather().
parents
72f8e256
f03b3c75
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
11 deletions
+23
-11
Lib/asyncio/tasks.py
Lib/asyncio/tasks.py
+23
-11
No files found.
Lib/asyncio/tasks.py
View file @
845212af
...
...
@@ -558,21 +558,33 @@ def gather(*coros_or_futures, loop=None, return_exceptions=False):
prevent the cancellation of one child to cause other children to
be cancelled.)
"""
arg_to_fut
=
{
arg
:
async
(
arg
,
loop
=
loop
)
for
arg
in
set
(
coros_or_futures
)}
children
=
[
arg_to_fut
[
arg
]
for
arg
in
coros_or_futures
]
n
=
len
(
children
)
if
n
==
0
:
if
not
coros_or_futures
:
outer
=
futures
.
Future
(
loop
=
loop
)
outer
.
set_result
([])
return
outer
arg_to_fut
=
{}
for
arg
in
set
(
coros_or_futures
):
if
not
isinstance
(
arg
,
futures
.
Future
):
fut
=
async
(
arg
,
loop
=
loop
)
if
loop
is
None
:
loop
=
fut
.
_loop
# The caller cannot control this future, the "destroy pending task"
# warning should not be emitted.
fut
.
_log_destroy_pending
=
False
else
:
fut
=
arg
if
loop
is
None
:
loop
=
children
[
0
].
_loop
for
fut
in
children
:
if
fut
.
_loop
is
not
loop
:
loop
=
fut
.
_loop
elif
fut
.
_loop
is
not
loop
:
raise
ValueError
(
"futures are tied to different event loops"
)
arg_to_fut
[
arg
]
=
fut
children
=
[
arg_to_fut
[
arg
]
for
arg
in
coros_or_futures
]
nchildren
=
len
(
children
)
outer
=
_GatheringFuture
(
children
,
loop
=
loop
)
nfinished
=
0
results
=
[
None
]
*
n
results
=
[
None
]
*
n
children
def
_done_callback
(
i
,
fut
):
nonlocal
nfinished
...
...
@@ -595,7 +607,7 @@ def gather(*coros_or_futures, loop=None, return_exceptions=False):
res
=
fut
.
_result
results
[
i
]
=
res
nfinished
+=
1
if
nfinished
==
n
:
if
nfinished
==
n
children
:
outer
.
set_result
(
results
)
for
i
,
fut
in
enumerate
(
children
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment