-
Notifications
You must be signed in to change notification settings - Fork 149
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
AsyncGenerator early exit doesn't raise CancelledError and doesn't run finally
branch
#759
Comments
I understand this is related to event_loop shutdown. If I add this
The 3 issues I mentioned are all gone, but there's this warning
Two related issues are |
Specifically, this line in event_loop shutdown fixes the issue
I don't know why pytest-asyncio decides not to do this like in the standard |
If instead of hacking the
then all the issues are gone. But, of course, regular user should not need to do that |
I agree that async generators should be cleaned up properly. Pytest-asyncio is currently in the middle of transitioning away from the The current v0.23 release still has some issues that have to be ironed out (especially #706), in order to provide a proper migration path for users. Once everything is done, I'm sure this issue will be resolved as well. |
My workaround above using |
This code:
Run it:
I was surprised to see
CancelledError
rather thanGeneratorExit
but it's OK. Now this code:Run it,
Now I don't understand why
CancelledError
was not raised, it appearsfinally
block was not executed, it appearsOf course, that "destroyed but it is pending" is also unpleasant to see.
Is there a bug in pytest-asyncio or am I missing something? I think this code should simply pass with no drama of any kind.
The text was updated successfully, but these errors were encountered: