New submission from Марк Коренберг: History:
First, I tried to debug code around asyncio.Task() cancelling. So I wrote: ===== try: ... except Exception as e: print(e) ===== When task was cancelled, an empty string printed. I wondered why. So I change the code to ==== print(repr(e)) ==== and it printed 'CancelledError' as expected. Next, I tried: ==== print(Exception()) ==== It prints empty string too! So I came up to propose API change. I propose to add argument to the .cancel() methods (for Task and for Future). This argument should be passed to the CancelledError constructor. This will greatly improves debugging -- it allows to easily know why Future/Task was cancelled. Also, this change does not break current code. Argument must be optional. ---------- components: asyncio messages: 299079 nosy: socketpair, yselivanov priority: normal severity: normal status: open title: Add argument to .cancel() of Task and Future type: enhancement versions: Python 3.5, Python 3.6, Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue31033> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com