GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-46771: Remove two controversial lines from Task.cancel() by gvanrossum · Pull Request #31623 · python/cpython

Conversation

@gvanrossum

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

Uh oh!

There was an error while loading. Please reload this page.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gvanrossum
Remove two controversial lines from Task.cancel()
0feaade
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.)
@gvanrossum
gvanrossum requested review from 1st1 and asvetlov as code owners February 28, 2022 20:21
@bedevere-bot bedevere-bot added the awaiting core review label Feb 28, 2022
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Feb 28, 2022
@gvanrossum gvanrossum added the skip news label Feb 28, 2022
@gvanrossum gvanrossum mentioned this pull request Feb 28, 2022
bpo-46771: Implement asyncio context managers for handling timeouts #31394
Merged
@agronholm

agronholm commented Feb 28, 2022

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented Feb 28, 2022

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

asvetlov
asvetlov approved these changes Feb 28, 2022
View reviewed changes

@asvetlov asvetlov left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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 :(

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Feb 28, 2022
@agronholm

agronholm commented Feb 28, 2022

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@agronholm

agronholm commented Feb 28, 2022

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum
gvanrossum merged commit 7d611b4 into main Feb 28, 2022
@gvanrossum
gvanrossum deleted the change-cancel branch February 28, 2022 23:15
@bedevere-bot bedevere-bot removed the awaiting merge label Feb 28, 2022
@gvanrossum

gvanrossum commented Feb 28, 2022

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Tinche

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@agronholm

agronholm commented Mar 1, 2022

Copy link
Copy Markdown
Contributor

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

gvanrossum reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum gvanrossum mentioned this pull request May 24, 2022
Implement asyncio.timeout() context manager #90927
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@asvetlov asvetlov asvetlov approved these changes
@1st1 1st1 Awaiting requested review from 1st1 1st1 is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@gvanrossum @agronholm @Tinche @asvetlov @the-knights-who-say-ni @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.