Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
The name parameter in theasyncio.create_task function is never passed to the event loop.
Task names are instead only ever set by theasyncio.create_task function and custom implementations of the event loop will not ever see the task name.
A crude demonstration of this issue is shown below
importasynciofromunittestimportmockclassTestLoop(asyncio.BaseEventLoop):defcreate_task(self,coro,*,name=None,context=None):ifcoro.__name__=="sleep":assertname=="bar"returnsuper().create_task(coro,name=name,context=context)classTestPolicy(asyncio.DefaultEventLoopPolicy):defnew_event_loop(self)->asyncio.AbstractEventLoop:loop=TestLoop()loop._process_events=mock.Mock()loop._write_to_self=mock.Mock()loop._write_to_self.return_value=Noneloop._selector=mock.Mock()loop._selector.select.return_value= ()loop.shutdown_ag_run=Falsereturnloopasyncdeffoo():asyncio.create_task(asyncio.sleep(0.1),name="bar", )defmain():asyncio.set_event_loop_policy(TestPolicy())asyncio.run(foo())if__name__=="__main__":main()
CPython versions tested on:
3.12
Operating systems tested on:
macOS
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status
Done