Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0cfa15c

Browse filesBrowse files
Pass name to loop create_task for TaskGroup
`TaskGroup.create_task` follows the same pattern as `asyncio.create_task`, also including a redundant call to `Task.set_name`. Note that `BaseEventLoop.create_task` uses the `task_factory` if it is set, in which does not accept a `name` kwarg. Hence, while we can remove the redundant call in `TaskGroup` we did not remove it in the `asyncio.create_task`
1 parent 8736f6c commit 0cfa15c
Copy full SHA for 0cfa15c

File tree

Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed

‎Lib/asyncio/taskgroups.py

Copy file name to clipboardExpand all lines: Lib/asyncio/taskgroups.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ def create_task(self, coro, *, name=None, context=None):
158158
if self._aborting:
159159
raise RuntimeError(f"TaskGroup {self!r} is shutting down")
160160
if context is None:
161-
task = self._loop.create_task(coro)
161+
task = self._loop.create_task(coro, name=name)
162162
else:
163-
task = self._loop.create_task(coro, context=context)
164-
task.set_name(name)
163+
task = self._loop.create_task(coro, name=name, context=context)
164+
165165
# optimization: Immediately call the done callback if the task is
166166
# already done (e.g. if the coro was able to complete eagerly),
167167
# and skip scheduling a done callback

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.