Author socketpair
Recipients socketpair, yselivanov
Date 2017-07-25.13:21:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1500988900.8.0.188595649246.issue31033@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-07-25 13:21:40socketpairsetrecipients: + socketpair, yselivanov
2017-07-25 13:21:40socketpairsetmessageid: <1500988900.8.0.188595649246.issue31033@psf.upfronthosting.co.za>
2017-07-25 13:21:40socketpairlinkissue31033 messages
2017-07-25 13:21:40socketpaircreate