Message309772
I have discoverd one very ugly pattern connected with asyncio. Many times I see code like this:
try:
await something()
except Exception:
log.error('Opertaion failed -- will retry later.')
Seems, everything is fine, but asyncio.CancelledError unintentionally
also suppressed in that code. So, sometimes coroutines are not cancellable.
In order to mitigate thi, we had to write:
try:
await something()
except CancelledError:
raise
except Exception:
log.error('Opertaion failed. will retry later.')
So, what I propose: Basically is to change base class for asyncio.CancelledError
from Exception (yes, I know concurrent.futures and it's `Error` class) to BaseException.
Just like `SystemExit` and other SPECIAL exceptions.
Yes, I know that it would be incompatible change. But I suspect that impact will be minimal. Documentation for concurrent.futures and asyncio does not say that this exception is derived from Exception. |
|
Date |
User |
Action |
Args |
2018-01-10 16:31:15 | socketpair | set | recipients:
+ socketpair, asvetlov, yselivanov |
2018-01-10 16:31:15 | socketpair | set | messageid: <1515601875.1.0.467229070634.issue32528@psf.upfronthosting.co.za> |
2018-01-10 16:31:15 | socketpair | link | issue32528 messages |
2018-01-10 16:31:14 | socketpair | create | |
|