Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-104144: Optimize gather to finish eagerly when all futures complete eagerly#104138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
gh-NNNN: Skip creating GatheringFuture if all futures finished eagerly
  • Loading branch information
@itamaro
itamaro committedMay 3, 2023
commitb3e479ac2830642ba6d4dcf22259e22a8145a2d9
16 changes: 14 additions & 2 deletionsLib/asyncio/tasks.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -815,6 +815,7 @@ def _done_callback(fut):
nfinished = 0
loop = None
outer = None # bpo-46672
all_finished = True
for arg in coros_or_futures:
if arg not in arg_to_fut:
fut = ensure_future(arg, loop=loop)
Expand All@@ -829,15 +830,26 @@ def _done_callback(fut):

nfuts += 1
arg_to_fut[arg] = fut
fut.add_done_callback(_done_callback)
if fut.done():
# call the callback immediately instead of scheduling it
_done_callback(fut)
else:
all_finished = False
fut.add_done_callback(_done_callback)

else:
# There's a duplicate Future object in coros_or_futures.
fut = arg_to_fut[arg]

children.append(fut)

outer = _GatheringFuture(children, loop=loop)
if all_finished:
# optimization: skip creating GatheringFuture if all children completed
# (e.g. when all coros are able to complete eagerly)
outer = futures.Future(loop=loop)
outer.set_result([c.result for c in children])
else:
outer = _GatheringFuture(children, loop=loop)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
outer=_GatheringFuture(children,loop=loop)
outer.__self_log_traceback=False
outer=_GatheringFuture(children,loop=loop)

return outer


Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp