This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author chris.jerdonek
Recipients chris.jerdonek, matrixise, socketpair, yselivanov
Date 2017-08-08.02:15:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
A couple thoughts on this issue:

First, I think the OP's original issue could perhaps largely be addressed without having to change cancel()'s signature. Namely, simply passing a hard-coded string to CancelledError in the couple spots that CancelledError is raised would cause the exception to display:

The "raise CancelledError" could be changed to "raise CancelledError('future is cancelled')", a bit like how InvalidStateError is handled a couple lines later:

    if self._state == _CANCELLED:
        raise CancelledError
    if self._state != _FINISHED:
        raise InvalidStateError('Result is not ready.')

Second, in terms of making cancellations easier to debug, is it a deliberate design decision that the CancelledError traceback "swallows" / doesn't show the point at which the coroutine was cancelled?

For example, running the following code--

    async def run():
        await asyncio.sleep(1000000)

    loop = asyncio.new_event_loop()
    task = asyncio.ensure_future(run(), loop=loop)
    loop.call_later(2, task.cancel)

Results in the following output:

    Traceback (most recent call last):
      File "", line 46, in <module>
      File "/Users/.../python3.6/asyncio/", line 466,
          in run_until_complete
        return future.result()

In particular, it doesn't show that the task was waiting on asyncio.sleep(1000000) when the task was cancelled. It would be very useful to see full tracebacks in these cases. (Sorry in advance if this second point is off-topic for this issue.)
Date User Action Args
2017-08-08 02:15:28chris.jerdoneksetrecipients: + chris.jerdonek, socketpair, yselivanov, matrixise
2017-08-08 02:15:28chris.jerdoneksetmessageid: <>
2017-08-08 02:15:28chris.jerdoneklinkissue31033 messages
2017-08-08 02:15:27chris.jerdonekcreate