Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
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
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
b3e479a8eeebaf9289c9eedbb04c9be6e51250b73c7df90ebce52714File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -815,6 +815,7 @@ def _done_callback(fut): | ||||||||
| nfinished = 0 | ||||||||
| loop = None | ||||||||
| outer = None # bpo-46672 | ||||||||
| all_finished = True | ||||||||
itamaro marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||||||||
| for arg in coros_or_futures: | ||||||||
| if arg not in arg_to_fut: | ||||||||
| fut = ensure_future(arg, loop=loop) | ||||||||
| @@ -829,15 +830,26 @@ def _done_callback(fut): | ||||||||
| nfuts += 1 | ||||||||
| arg_to_fut[arg] = fut | ||||||||
| if fut.done(): | ||||||||
| # call the callback immediately instead of scheduling it | ||||||||
| _done_callback(fut) | ||||||||
| else: | ||||||||
| all_finished = False | ||||||||
itamaro marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||||||||
| 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) | ||||||||
| if all_finished: | ||||||||
itamaro marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||||||||
| # optimization: skip creating GatheringFuture if all children completed | ||||||||
| # (e.g. when all coros are able to complete eagerly) | ||||||||
| outer = futures.Future(loop=loop) | ||||||||
itamaro marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||||||||
| outer.set_result([c.result for c in children]) | ||||||||
itamaro marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||||||||
| else: | ||||||||
| outer = _GatheringFuture(children, loop=loop) | ||||||||
| ||||||||
| outer=_GatheringFuture(children,loop=loop) | |
| outer.__self_log_traceback=False | |
| outer=_GatheringFuture(children,loop=loop) |