Conversation
Member
|
I don't feel like I'm qualified to review this given my current knowledge of async implementation. Can you walk me through the PR in person and explain how everything works along the way? |
sandersn
approved these changes
May 3, 2017
Member
sandersn
left a comment
There was a problem hiding this comment.
Thanks for the tutorial on async generators!
Contributor
|
@rbuckton can you port this change to release-2.3 |
This was referenced May 4, 2017
Contributor
Author
|
@mhegazy this is now in release-2.3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
return()is called on a generator that is in the process ofyield*delegation, it should not only callreturn()on the delegated iterable, but should also exit the current generator. The__asyncDelegatorprocesses each call in two steps: first it indicates to the outer generator that it should await the result of a call tonext,throw, orreturn, then it returns the result of thatawaitoperation in a tick/tock fashion.When the delegator "ticks", it returns an
IteratorResultthat looks like:{ value: ["await", result], done: false }. The outer async generator will handle theawaitand call back into the delegator ("tock"). When the delegator "tocks", it processes the iterator result and either exits with adone: trueor yields with a{ value: ["yield", value], done: false }.The problem lies in the fact that when the delegator "ticks" as part of a call to
return(), it returnsdone: false. This informs the underlying generator runtime that the delegator did not actually close, so it continues processing. This change now unconditionally causes the delegator to return by always returningdone: truewhen callingreturn()on an async delegator.This change also awaits the result of an async delegator (the x in
x = yield* y) to more closely align with the async iteration proposal.Fixes #15471