[issue46829] Confusing CancelError message if multiple cancellations are scheduled

2022-03-23 Thread Guido van Rossum
Guido van Rossum added the comment: Fixed by deprecating the message argument to cancel(). It will be removed in 3.13. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue46829] Confusing CancelError message if multiple cancellations are scheduled

2022-03-23 Thread Guido van Rossum
Guido van Rossum added the comment: New changeset 0360e9f34659e7d7f3dae021b82f78452db8c714 by Andrew Svetlov in branch 'main': bpo-46829: Deprecate passing a message into Future.cancel() and Task.cancel() (GH-31840) https://github.com/python/cpython/commit/0360e9f34659e7d7f3dae021b82f78452db

[issue46829] Confusing CancelError message if multiple cancellations are scheduled

2022-03-13 Thread Yury Selivanov
Yury Selivanov added the comment: IOW I think that supporting custom messages is a needless complication of our API. Given how complex task trees can become with TaskGroups collecting those messages and presenting them all to the user isn't trivial, showing just first/last defeats the purpos

[issue46829] Confusing CancelError message if multiple cancellations are scheduled

2022-03-13 Thread Yury Selivanov
Yury Selivanov added the comment: Andrew asked me for my opinion on the matter -- I think we should get rid of the message. Exception messages for "signals" can be easily lost if an exception was re-raised. If the reason of why something is being cancelled is important (in my experience it

[issue46829] Confusing CancelError message if multiple cancellations are scheduled

2022-03-12 Thread Andrew Svetlov
Andrew Svetlov added the comment: If the cancellation message should be kept it needs improvements anyway, the single message doesn't work well with multiple `.cancel()` calls. I can imagine a 'CancelledError(*msgs)' and 'raise exc.drop_msg(msg)' as a function equivalent of task cancellation

[issue46829] Confusing CancelError message if multiple cancellations are scheduled

2022-03-12 Thread Guido van Rossum
Guido van Rossum added the comment: Before we land GH-31840 we should have a somewhat more public discussion (e.g. on python-dev or maybe in Async-SIG, https://discuss.python.org/c/async-sig/20; or at least here) about deprecating the cancel message. I'm all for it but certainly Chris Jerdon

[issue46829] Confusing CancelError message if multiple cancellations are scheduled

2022-03-12 Thread Andrew Svetlov
Change by Andrew Svetlov : -- keywords: +patch pull_requests: +29940 stage: -> patch review pull_request: https://github.com/python/cpython/pull/31840 ___ Python tracker ___ _

[issue46829] Confusing CancelError message if multiple cancellations are scheduled

2022-02-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: For reference, the msg parameter of Task.cancel() was added in issue31033. It seems that the initial use case was for debugging. I do not see how it differs from the following example: r = random.random() if r < 0.5: x = 0 else:

[issue46829] Confusing CancelError message if multiple cancellations are scheduled

2022-02-23 Thread Guido van Rossum
Guido van Rossum added the comment: But that example is made-up. Is there a real-world situation where you need to know the call site, and it wouldn't be obvious from other log messages? Directly cancelling a task without also somehow catching the cancellation (like in the timeout or task gr

[issue46829] Confusing CancelError message if multiple cancellations are scheduled

2022-02-22 Thread Chris Jerdonek
Chris Jerdonek added the comment: I don't really understand all the hate around the idea of a cancel message. One reason it's useful is that it provides a simple way to say *why* something is being cancelled or *what* is cancelling it. It provides additional context to the exception, in the

[issue46829] Confusing CancelError message if multiple cancellations are scheduled

2022-02-22 Thread Andrew Svetlov
Andrew Svetlov added the comment: Deprecation is a good answer. Let's not forget to apply it to 3.11 then. -- ___ Python tracker ___ _

[issue46829] Confusing CancelError message if multiple cancellations are scheduled

2022-02-22 Thread Guido van Rossum
Guido van Rossum added the comment: I would like to go on record (again) as preferring to get rid of the cancel-message parameter altogether. Let's deprecate it. When we initially designed things without a cancel message we did it on purpose -- "cancellation" is a single flag, not a collecti

[issue46829] Confusing CancelError message if multiple cancellations are scheduled

2022-02-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: What about `CancelledError(*msg_list)` or `CancelledError(*reversed(msg_list))`? It is backward compatible and all messages are uniformely represented. -- nosy: +serhiy.storchaka ___ Python tracker

[issue46829] Confusing CancelError message if multiple cancellations are scheduled

2022-02-22 Thread Andrew Svetlov
New submission from Andrew Svetlov : Suppose multiple `task.cancel(msg)` with different messages are called on the same event loop iteration. What message (`cancel_exc.args[0]`) should be sent on the next loop iteration? As of Python 3.10 it is the message from the *last* `task.cancel(msg)` c