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 thehesiod
Recipients chris.jerdonek, matrixise, socketpair, thehesiod, yselivanov
Date 2018-04-04.21:56:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1522878972.89.0.682650639539.issue31033@psf.upfronthosting.co.za>
In-reply-to
Content
I was about to open a new bug, but I think my idea overlaps with this one.  From what I understand there are two ways to cancel tasks:

1) calling task.cancel()
2) explicitly raising a CancelledError

with #2 you can get a traceback by catching the exception which yields why the task was cancelled (per callstack, and you create the CancelledError with a custom message).

#1 I think is what this is talking about.

The most useful information IMHO is the callstack, and via #1 this callstack is completely lost.

I like the idea of having an argument to construct the CancelledError with, but I like even more the ability to tell the exception that will be raised to have the traceback of the point where the task was originally cancelled.

Right now I have to use forbidden fruit to override the Task.cancel method and store the callstack in a custom attribute.

I was talking with asvetlov and and he thought perhaps there could be an environment variable to enable this by default and then when the cancellation error is raised it can have the caller's callstack...I think ideally this would be the default if it could be done cheaply (given if a regular exception throw contains the callstack, then a cancellation exception should always as well.

Ideally I think when a task is cancelled it instantiates the exception with the callstack at that point, and then does something like a "with e" to raise the exception from the future so you get it when it's raised.
History
Date User Action Args
2018-04-04 21:56:12thehesiodsetrecipients: + thehesiod, chris.jerdonek, socketpair, yselivanov, matrixise
2018-04-04 21:56:12thehesiodsetmessageid: <1522878972.89.0.682650639539.issue31033@psf.upfronthosting.co.za>
2018-04-04 21:56:12thehesiodlinkissue31033 messages
2018-04-04 21:56:12thehesiodcreate