Message299079
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. |
|
Date |
User |
Action |
Args |
2017-07-25 13:21:40 | socketpair | set | recipients:
+ socketpair, yselivanov |
2017-07-25 13:21:40 | socketpair | set | messageid: <1500988900.8.0.188595649246.issue31033@psf.upfronthosting.co.za> |
2017-07-25 13:21:40 | socketpair | link | issue31033 messages |
2017-07-25 13:21:40 | socketpair | create | |
|