-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
async generator receives wrong value when shared between coroutines #74956
Comments
MRE
Produces output:
Expected output (some variance allowed):
Initial report / discussion: https://mail.python.org/pipermail/async-sig/2017-June/000293.html |
@yuri, this bug doesn't require
Same with |
Note that the example can be further simplified by replacing user() with: async def send_hello(g):
print("sending: hello")
await g.asend("hello") Then the output is: sending: hello |
I've reproduced the problem also in 3.7 branch.
Output:
If the line
|
Thanks Jan. Thanks a lot for a short script to reproduce this bug. The actual problem here is that asynchronous generators don't control their 'asend' and 'athrow' coroutines in any way. So if you have two of them iterating *in parallel* they will cause their asynchronous generator to be in an inconsistent state. The most obvious solution to this problem is to prohibit iterating 'asend'/'athrow' objects in parallel by throwing an exception. Nathaniel, what are your thoughts on this? |
My thoughts: https://bugs.python.org/issue32526#msg309783 |
Thanks, I'll look into adding ag_running properly. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
The text was updated successfully, but these errors were encountered: