graingert · GitHub

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

Linked PRs

Read the original on github.com ↗