-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-108951: document addition of TaskGroup.cancel() #149031
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -717,6 +717,14 @@ ast | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This can be :ref:`controlled using environment variables <using-on-controlling-color>`. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (Contributed by Stan Ulbrych in :gh:`148981`.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| asyncio | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Added :meth:`~asyncio.TaskGroup.cancel` to allow early termination of a task group -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| e.g. when the goal of the tasks has been achieved or their services no longer needed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Previously this would involve unintuitive boilerplate such as an extra task raising | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| a custom exception which is then suppressed as it exits TaskGroup. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (Contributed by John Belmonte in :gh:`127214`.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| base64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
718
to
729
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just flat out wrong.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I removed the word "group". Thanks for finding it. I just wanted to reflow the paragraph. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| Add :meth:`~asyncio.TaskGroup.cancel` which cancels unfinished tasks and exits the group without error. | ||
| Add :meth:`~asyncio.TaskGroup.cancel` which cancels unfinished tasks and exits the group without raising :exc:`asyncio.CancelledError`. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm still not sure if the explicit "and exits the group without raising :exc:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Further, this still begs to question why you said "without raising :exc:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, if you check the long discussions in the impl PR, there was quite a bit made about possible confusion from expecting TaskGroup.cancel() to behave like Task.cancel(). So this is being explicit that unlike the latter, TaskGroup.cancel() does not cause anything to raise CancelledError.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this could be reworded: Add :meth: Thoughts? |
||
Uh oh!
There was an error while loading. Please reload this page.