8000 gh-104144: Skip scheduling a done callback if a TaskGroup task completes eagerly by itamaro · Pull Request #104140 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content 8000

gh-104144: Skip scheduling a done callback if a TaskGroup task completes eagerly #104140

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
May 5, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
revert skipping _set_task_name if name is None; fix typo in comment
  • Loading branch information
itamaro committed May 5, 2023
commit 161d0f8c6f0241bb20f887522659b1bc8700452d
5 changes: 2 additions & 3 deletions Lib/asyncio/taskgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,8 @@ def create_task(self, coro, *, name=None, context=None):
task = self._loop.create_task(coro)
else:
task = self._loop.create_task(coro, context=context)
if name is not None:
tasks._set_task_name(task, name)
# optimization: Immediately call the done callback is the task is
tasks._set_task_name(task, name)
# optimization: Immediately call the done callback if the task is
# already done (e.g. if the coro was able to complete eagerly),
# and skip scheduling a done callback
if task.done():
Expand Down
0