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']
3.13
Linux
The task name should be passed when calling the task factory itself otherwise the first eager execution misses the set name.
We should probably just pass the **kwargs without inspection
Feel free to propose an PR.
pythongh-128308: pass **kwargs to asyncio task_factory
@kumaraditya303 I've proposed a PR
gh-128308: pass `**kwargs` to asyncio task_factory (#128768)
pythongh-128308: pass `**kwargs` to asyncio task_factory (python#128768)
[3.13] pythongh-128308: pass `**kwargs` to asyncio task_factory (pyth…
[3.13] gh-128308: pass `**kwargs` to asyncio task_factory (GH-128768) (…
Revert "[3.13] pythongh-128308: pass `**kwargs` to asyncio task_facto…
Activity
kumaraditya303 commented on Jan 8, 2025
The task name should be passed when calling the task factory itself otherwise the first eager execution misses the set name.
graingert commented on Jan 8, 2025
We should probably just pass the **kwargs without inspection
kumaraditya303 commented on Jan 9, 2025
Feel free to propose an PR.
pythongh-128308: pass **kwargs to asyncio task_factory
pythongh-128308: pass **kwargs to asyncio task_factory
graingert commented on Jan 15, 2025
@kumaraditya303 I've proposed a PR
gh-128308: pass `**kwargs` to asyncio task_factory (#128768)
pythongh-128308: pass `**kwargs` to asyncio task_factory (python#128768)
[3.13] pythongh-128308: pass `**kwargs` to asyncio task_factory (pyth…
[3.13] gh-128308: pass `**kwargs` to asyncio task_factory (GH-128768) (…
Revert "[3.13] pythongh-128308: pass `**kwargs` to asyncio task_facto…