Author socketpair
Recipients asvetlov, socketpair, yselivanov
Date 2018-01-10.16:31:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1515601875.1.0.467229070634.issue32528@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-01-10 16:31:15socketpairsetrecipients: + socketpair, asvetlov, yselivanov
2018-01-10 16:31:15socketpairsetmessageid: <1515601875.1.0.467229070634.issue32528@psf.upfronthosting.co.za>
2018-01-10 16:31:15socketpairlinkissue32528 messages
2018-01-10 16:31:14socketpaircreate