-
-
Notifications
You must be signed in to change notification settings - Fork 140
When MapAsyncIterator is cancelled, the underlying __anext__ task is not cancelled #131
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
Conversation
…tasks cancel exception is not caught and the internal __aiter__ task will not be stopped.
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.
Thank you for this PR which looks reasonable to me. If possible, improve the formatting and test coverage so that CI tests pass. Otherwise let me know, I can do the polishing then.
@Cito There might be a break change. Previously the exception of try:
async for result in iterator:
...
# After StopAsyncIteration
except BaseException as e:
...
|
Also the Iterator should be marked as is_closed in the except block. |
@Cito I have fixed the code according to the guideline. My test code is quite shabby that requires some asyncio.sleep because it may otherwise not triggering the errors. I may need your help to normalize the techniques. |
Thank you for adding the test. I think using asyncio.sleep is ok. In principle, we could use something like aiofastforward or asyncio-time-travel to make it run faster, but I don't want to add yet another 3rd party pytest plugin.
In fact I also thought of re-raising CancelledError instead. Let's fix it that way first, it looks like the right/safe thing to do. Let me know if you want to change it or I shall do it. |
@Cito I'm currently away from my computer. It would be nice if you can help change the code and tests. Thank you. |
Ok, I'll take care of this. Thanks for the contribution. |
As discussed in #131, better than conversion to StopAsyncIteration.
Hi @Cito, can I ask when will the update release with this fix? |
I want to release 3.1.5 with this fix as soon as I caught up with all changes in graphql-js 15.4.0, probably end of this week. Please check whether the current main branch works for you. I have already made the mentioned changes. |
@Cito Thank you for the information |
Sorry, could not finish the release this week. May take one or two weeks longer. |
@Cito Not at all! Thanks for the information! |
Found some time to publish the release today. |
No description provided.