aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/asyncio/taskgroups.py
diff options
context:
space:
mode:
authorJamie <101677823+ordinary-jamie@users.noreply.github.com>2023-12-13 12:26:40 +1100
committerGitHub <noreply@github.com>2023-12-12 17:26:40 -0800
commita3a1cb48456c809f7b1ab6a6ffe83e8b3f69be0f (patch)
tree3db53a3a61bae19902af9f2b962545ee96a88952 /Lib/asyncio/taskgroups.py
parentc6e614fd81d7dca436fe640d63a307c7dc9f6f3b (diff)
downloadcpython-a3a1cb48456c809f7b1ab6a6ffe83e8b3f69be0f.tar.gz
cpython-a3a1cb48456c809f7b1ab6a6ffe83e8b3f69be0f.zip
gh-112622: Pass name to loop create_task method (#112623)
This affects task creation through either `asyncio.create_task()` or `TaskGroup.create_task()` -- the redundant call to `task.set_name()` is skipped. We still call `set_name()` when a task factory is involved, because the task factory call signature (unfortunately) doesn't take a `name` argument.
Diffstat (limited to 'Lib/asyncio/taskgroups.py')
-rw-r--r--Lib/asyncio/taskgroups.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/asyncio/taskgroups.py b/Lib/asyncio/taskgroups.py
index 91be0decc41..cb9c1ce4d7d 100644
--- a/Lib/asyncio/taskgroups.py
+++ b/Lib/asyncio/taskgroups.py
@@ -158,10 +158,10 @@ class TaskGroup:
if self._aborting:
raise RuntimeError(f"TaskGroup {self!r} is shutting down")
if context is None:
- task = self._loop.create_task(coro)
+ task = self._loop.create_task(coro, name=name)
else:
- task = self._loop.create_task(coro, context=context)
- task.set_name(name)
+ task = self._loop.create_task(coro, name=name, context=context)
+
# 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