Alexander Mohr <thehes...@gmail.com> added the comment: 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. ---------- nosy: +thehesiod _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31033> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com