Skip to content

bpo-46771: cancel counts - #31434

Merged
asvetlov merged 6 commits into
python:issue-46771from
asvetlov:issue-46771-cancel-counts
Feb 21, 2022
Merged

bpo-46771: cancel counts#31434
asvetlov merged 6 commits into
python:issue-46771from
asvetlov:issue-46771-cancel-counts

Conversation

@Tinche

@TincheTinche commented Feb 20, 2022

Copy link
Copy Markdown
Contributor

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

@asvetlovasvetlov changed the title Issue 46771 cancel counts bpo-46771: cancel countsFeb 20, 2022
@Tinche
Tincheforce-pushed the issue-46771-cancel-counts branch from 4526894 to b32bbf9CompareFebruary 20, 2022 23:03
@asvetlov

Copy link
Copy Markdown
Contributor

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

@Tinche

Copy link
Copy Markdown
ContributorAuthor

@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
Copy Markdown
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

Copy link
Copy Markdown
ContributorAuthor

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

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

Copy link
Copy Markdown

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

@asvetlov

Copy link
Copy Markdown
Contributor

Done. Thanks!

@asvetlov
asvetlov deleted the issue-46771-cancel-counts branch February 21, 2022 00:10
Sign up for freeto 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

@Tinche@asvetlov@bedevere-bot@the-knights-who-say-ni