Skip to content

TaskGroup fails to cancel tasks pending creation, if that task starts a failing task #128550

Description

@graingert

Bug report

Bug description:

this 'deadlocks' on eager tasks, but raises an EG as expected on regular 'lazy' tasks.

importsysimportasyncioifsys.version_info>= (3, 13):
fromasyncioimportEventLoopelifsys.platform=="win32":
fromasyncioimportProactorEventLoopasEventLoopelse:
fromasyncioimportSelectorEventLoopasEventLoopdefloop_factory():
loop=EventLoop()
loop.set_task_factory(asyncio.eager_task_factory)
returnloopasyncdefmain():
asyncwithasyncio.TaskGroup() astg:
asyncdefthird_task():
raiseRuntimeError("third task failed")
asyncdefsecond_task():
tg.create_task(third_task())
awaitasyncio.Event().wait()
tg.create_task(second_task())
# asyncio.run(main())asyncio.run(main(), loop_factory=loop_factory)

CPython versions tested on:

3.12, 3.13, 3.14

Operating systems tested on:

Linux

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