New submission from Марк Коренберг <socketp...@gmail.com>:

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.

----------
components: asyncio
messages: 309772
nosy: asvetlov, socketpair, yselivanov
priority: normal
severity: normal
status: open
title: Change base class for futures.CancelledError
versions: Python 3.7, Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32528>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to