FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-46771: Remove two controversial lines from Task.cancel() by gvanrossum · Pull Request #31623 · python/cpython · GitHub

/ cpython Public

bpo-46771: Remove two controversial lines from Task.cancel() - #31623

Merged
gvanrossum merged 1 commit into
mainfrom
change-cancel
Feb 28, 2022
Merged

bpo-46771: Remove two controversial lines from Task.cancel()#31623
gvanrossum merged 1 commit into
mainfrom
change-cancel

Conversation

gvanrossum commented Feb 28, 2022
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

Also from the _asyncio C accelerator module,
and adjust one test that the change caused to fail.

For more discussion see the discussion starting here:
#31394 (comment)

(Basically, @asvetlov proposed to return False from cancel()
when there is already a pending cancellation, and I went along,
even though it wasn't necessary for the task group implementation,
and @agronholm has come up with a counterexample that fails
because of this change. So now I'm changing it back to the old
semantics (but still bumping the counter) until we can have a
proper discussion about this.)

https://bugs.python.org/issue46771

Also from the _asyncio C accelerator module,
and adjust one test that the change caused to fail.

For more discussion see the discussion starting here:
#31394 (comment)

(Basically, @asvetlov proposed to return False from cancel()
when there is already a pending cancellation, and I went along,
even though it wasn't necessary for the task group implementation,
and @agronholm has come up with a counterexample that fails
because of this change.  So now I'm changing it back to the old
semantics (but still bumping the counter) until we can have a
proper discussion about this.)

Copy link
Copy Markdown
Contributor

This seems like a step in the right direction, but further changes will be necessary.

Copy link
Copy Markdown
Member Author

This seems like a step in the right direction, but further changes will be necessary.

Could you be more specific? What use case are you thinking of?

asvetlov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm fine with this.
.uncancel() makes the change not necessary.
Deprecation of cancellation message clears my other objections.
Sorry, I'm not active this week. Hard events in my life :(

Copy link
Copy Markdown
Contributor

This seems like a step in the right direction, but further changes will be necessary.

Could you be more specific? What use case are you thinking of?

Unless more changes are made, old-style cancel scope-like context managers will distort the cancel counter. It should be reset to 0 when the task is made cancellable again (when the CancelledError has been delivered to the task). This should improve the interaction of counter-aware context managers and non-aware ones by letting the aware ones function correctly in the case of a re-cancellation when the aware context manager is the outer one and the non-aware one is the inner one.

Copy link
Copy Markdown
Contributor

Ideally I would have liked the CancelledError to carry this information. That would make it easier to write code compatible with 3.9 - 3.10 since those versions will have to use the cancel message trick.

gvanrossum merged commit 7d611b4 into main Feb 28, 2022
gvanrossum deleted the change-cancel branch February 28, 2022 23:15

Copy link
Copy Markdown
Member Author

@agronholm Would you mind submitting a (draft) PR? I personally think that if we have a solution that will work great in the future, making the existing cancel scope implementations have to do a version check would be a small price to pay.

Tinche commented Mar 1, 2022

Copy link
Copy Markdown
Contributor

Could you also tag me in that PR? Trying to wrap my head around the issue.

Copy link
Copy Markdown
Contributor

I'm currently on a work trip but will try work on that in the next few days.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants


Back | FazBrowse Home | New Git URL