mirror of
https://github.com/python/cpython.git
synced 2025-10-28 12:15:13 +00:00
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.
This commit is contained in:
parent
c6e614fd81
commit
a3a1cb4845
3 changed files with 7 additions and 6 deletions
|
|
@ -404,11 +404,10 @@ def create_task(coro, *, name=None, context=None):
|
|||
loop = events.get_running_loop()
|
||||
if context is None:
|
||||
# Use legacy API if context is not needed
|
||||
task = loop.create_task(coro)
|
||||
task = loop.create_task(coro, name=name)
|
||||
else:
|
||||
task = loop.create_task(coro, context=context)
|
||||
task = loop.create_task(coro, name=name, context=context)
|
||||
|
||||
task.set_name(name)
|
||||
return task
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue