Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

create_task does not pass name parameter to event loop #112622

Closed
Labels
stdlibStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or error
@ordinary-jamie

Description

@ordinary-jamie

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

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp