-
Notifications
You must be signed in to change notification settings - Fork 232
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
Check if Task(Future) is canceled. #1377
base: rolling
Are you sure you want to change the base?
Conversation
Signed-off-by: Tomoya Fujita <[email protected]>
Please backport this bugfix into humble/jazzy. |
Hey, def cancel(self):
if not self._done and iscoroutine(self._handle):
self._handle.close()
super().cancel() We can at least fix the bug at hand and concentrate on improving on the functionality after? |
@nadavelkabets @weber-niklas sorry guys for being late to get back to this, i will try to allocate some time for this in next week. |
I created PR #1392 to fix the unawaited coroutine issue based on my first suggestion. It's not yet complete since we need to figure out how to handle the CancelledException in a way that won't crash the executor. I believe we should first go with a solution that we can backport into jazzy. |
@nadavelkabets again thank you very much for helping this one moving forward 👍 i have already #1394 merged in this PR.
agree, this is also broken in jazzy and humble.
IMO, we can go with suggestion 2 (coroutine close, that is currently implemented in this PR) to avoid surprising the application with new exception generated by task cancel. that said it does not break the user space, user application can have the fix and also no user code change is required. And then probably we can move on to #1392 for rolling branch. i think having the capability for clean-up in the user callback makes sense for canceling tasks.
i will look into this for sure and leave some comments. |
* Add FutureState Signed-off-by: Nadav Elkabets <[email protected]> * Close canceled coroutine Signed-off-by: Nadav Elkabets <[email protected]> * Fixed behavior in test Signed-off-by: Nadav Elkabets <[email protected]> --------- Signed-off-by: Nadav Elkabets <[email protected]> Signed-off-by: Tomoya Fujita <[email protected]>
Signed-off-by: Tomoya Fujita <[email protected]>
c3107d6
to
59000b6
Compare
# Get rid of any tasks that are cancelled | ||
self._tasks = list(filter(lambda t_e_n: not t_e_n[0].cancelled(), self._tasks)) |
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.
Missed this line in my PR, not needed anymore since done() now returns true if cancelled.
There are some other duplicate checks for done and cancelled, I'll review the code again to look for them.
closes #1099