8000 bpo-46771: cancel counts by Tinche · Pull Request #31434 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-46771: cancel counts #31434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 21, 2022

Conversation

Tinche
Copy link
Contributor
@Tinche Tinche commented Feb 20, 2022

Changes:

  • Task._cancel_requested: bool is now Task._num_cancels_requested: int
  • Task.cancelling now returns an int
  • Task.uncancel also returns an int, the number of remaining cancel requests
  • the CancelScope no longer cancels with a nonce
  • the CancelScope uncancels in __exit__, and propagates the CancelError if there are more cancel requests
  • CancelScope.cancelled is now a property
  • added a couple of tests, not final

I have not updated any of the comments or docs yet.

https://bugs.python.org/issue46771

@asvetlov asvetlov changed the title Issue 46771 cancel counts bpo-46771: cancel counts Feb 20, 2022
@Tinche Tinche force-pushed the issue-46771-cancel-counts branch from 4526894 to b32bbf9 Compare February 20, 2022 23:03
@asvetlov
Copy link
Contributor

I like it!
Please feel free to press 'Merge' when you are ready.

@Tinche
Copy link
Contributor Author
Tinche commented Feb 20, 2022

@asvetlov this is a competing proposal to using the _COUNTERS dict, so maybe we should discuss this further? This makes the cancel count be on the task, instead of in the dict.

@asvetlov
Copy link
Contributor

I understand.
I have a feeling that your approach is better, it doesn't throw TimeoutError if the task was explicitly cancelled.

@Tinche Tinche marked this pull request as ready for review February 20, 2022 23:59
@Tinche Tinche requested review from 1st1 and asvetlov as code owners February 20, 2022 23:59
@Tinche
Copy link
Contributor Author
Tinche commented Feb 21, 2022

@asvetlov Cool, but you'll need to merge this :)

@asvetlov asvetlov merged commit a926bf0 into python:issue-46771 Feb 21, 2022
@bedevere-bot
Copy link

@asvetlov: Please replace # with GH- in the commit message next time. Thanks!

@asvetlov
Copy link
Contributor

Done. Thanks!

@asvetlov asvetlov deleted the issue-46771-cancel-counts branch February 21, 2022 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0