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 carljm, chris.jerdonek, matrixise, socketpair, thehesiod, yselivanov
Date 2020-05-16.01:06:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1589591187.33.0.68762231891.issue31033@roundup.psfhosted.org>
In-reply-to
Content
I just want to flag one issue after rebasing my traceback PR onto what was merged. If task.cancel() is called like this--

    task.cancel("POSSIBLY LONG CANCEL MESSAGE")

There is the question of whether the passed message should be repeated each time the CancelledError is raised, or only show it in the innermost, originating exception. My preference is to do the latter because it is simpler, less verbose, and seems more correct from a Python perspective. But I wanted to flag this because the message won't be visible in the leading, outermost exception.

There is a third alternative which is to mutate the exception each time (delete the message from the earlier exception and add it to the new exception). But that seems more fraught and what I'd consider surprising behavior.

Lastly, to illustrate, here is the more verbose option (the one I think it **shouldn't** look like):

Traceback (most recent call last):
  File "/.../cpython/test-cancel.py", line 4, in nested
    await asyncio.sleep(1)
  File "/.../cpython/Lib/asyncio/tasks.py", line 670, in sleep
    return await future
asyncio.exceptions.CancelledError: POSSIBLY LONG CANCEL MESSAGE

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/.../cpython/test-cancel.py", line 11, in run
    await task
asyncio.exceptions.CancelledError: POSSIBLY LONG CANCEL MESSAGE

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/.../cpython/test-cancel.py", line 15, in <module>
    loop.run_until_complete(run())
  File "/.../cpython/Lib/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
asyncio.exceptions.CancelledError: POSSIBLY LONG CANCEL MESSAGE
History
Date User Action Args
2020-05-16 01:06:27chris.jerdoneksetrecipients: + chris.jerdonek, carljm, socketpair, yselivanov, matrixise, thehesiod
2020-05-16 01:06:27chris.jerdoneksetmessageid: <1589591187.33.0.68762231891.issue31033@roundup.psfhosted.org>
2020-05-16 01:06:27chris.jerdoneklinkissue31033 messages
2020-05-16 01:06:27chris.jerdonekcreate