Skip to content
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

asyncio eager tasks' names are set too late #128308

Open
graingert opened this issue Dec 28, 2024 · 0 comments
Open

asyncio eager tasks' names are set too late #128308

graingert opened this issue Dec 28, 2024 · 0 comments
Labels
stdlib Python modules in the Lib dir topic-asyncio type-bug An unexpected behavior, bug, or error

Comments

@graingert
Copy link
Contributor

graingert commented Dec 28, 2024

Bug report

Bug description:

consider:

import asyncio

async def main():
    names = []
    async with asyncio.TaskGroup() as tg:
        async def append_name():
            names.append(asyncio.current_task().get_name())

        tg.create_task(append_name(), name="example name")
    print(names)

def loop_factory():
    loop = asyncio.EventLoop()
    loop.set_task_factory(asyncio.eager_task_factory)
    return loop

asyncio.run(main())
asyncio.run(main(), loop_factory=loop_factory)

this outputs:

['example name']
['Task-5']

but it should output:

['example name']
['example name']

CPython versions tested on:

3.13

Operating systems tested on:

Linux

@graingert graingert added type-bug An unexpected behavior, bug, or error topic-asyncio labels Dec 28, 2024
@github-project-automation github-project-automation bot moved this to Todo in asyncio Dec 28, 2024
@picnixz picnixz added the stdlib Python modules in the Lib dir label Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-asyncio type-bug An unexpected behavior, bug, or error
Projects
Status: Todo
Development

No branches or pull requests

2 participants