-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
add async generators section to asyncio internal docs #135674
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well written IMO (apart from a few small grammar things).
I love the flowchart, I had no idea github supports them!
Co-authored-by: Stan Ulbrych <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review (I have been procrastinating on all sorts of stuff :-( ). Looks good, only a few nits.
[`asyncio`](https://docs.python.org/3/library/asyncio.html) module. | ||
|
||
# Task management |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC this section only discusses the C version -- can you call that out somehow? Previously that was implied by the opening sentence above but that has changed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a sentence before both section to clarify that.
|
||
The above code will not print "finally executed", because the | ||
async generator `agen` is not fully iterated over | ||
and it is not closed manually by awaiting `agen.aclose()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is agen.aclose()
a shortcut for something? You cannot literally do that ('function' object has no attribute 'aclose'
). So what should I wrote to close it manually (if I was so inclined)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do something like this to close it:
async def main():
g = agen()
async for i in g:
break
await g.aclose()
Co-authored-by: Guido van Rossum <[email protected]>
This documents the implementation details of async generators in
asyncio
.