This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dreamsorcerer
Recipients asvetlov, dreamsorcerer, yselivanov
Date 2021-09-04.13:17:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <[email protected]>
In-reply-to
Content
There are awkward edge cases caused by race conditions when cancelling tasks which make it impossible to reliably cancel a task.

For example, in the async-timeout library there appears to be no way to avoid suppressing an explicit t.cancel() if that cancellation occurs immediately after the timeout.

In the alternative case where a cancellation happens immediately before the timeout, the solutions feel dependant on the internal details of how asynico.Task works and could easily break if the behaviour is tweaked in some way.

What we really need to know is how many times a task was cancelled as a cause of the CancelledError and ideally were the cancellations caused by us.

The solution I'd like to propose is that the args on the exception contain all the messages of every cancel() call leading up to that exception, rather than just the first one.

e.g. In these race conditions e.args would look like (None, SENTINEL), where SENTINEL was sent in our own cancellations. From this we can see that the task was cancelled twice and only one was caused by us, therefore we don't want to suppress the CancelledError.

For more details to fully understand the problem:
https://github.com/aio-libs/async-timeout/pull/230
https://github.com/aio-libs/async-timeout/issues/229#issuecomment-908502523
https://github.com/aio-libs/async-timeout/pull/237
History
Date User Action Args
2021-09-04 13:17:43dreamsorcerersetrecipients: + dreamsorcerer, asvetlov, yselivanov
2021-09-04 13:17:43dreamsorcerersetmessageid: <[email protected]>
2021-09-04 13:17:43dreamsorcererlinkissue45098 messages
2021-09-04 13:17:43dreamsorcerercreate