Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
graingert opened this issue Jan 6, 2025 · 0 comments
Labels
stdlib Python modules in the Lib dir topic-asyncio type-bug An unexpected behavior, bug, or error

Comments

@graingert
Copy link
Contributor

graingert commented Jan 6, 2025

Bug report

Bug description:

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

import sys
import asyncio


if sys.version_info >= (3, 13):
    from asyncio import EventLoop
elif sys.platform == "win32":
    from asyncio import ProactorEventLoop as EventLoop
else:
    from asyncio import SelectorEventLoop as EventLoop


def loop_factory():
    loop = EventLoop()
    loop.set_task_factory(asyncio.eager_task_factory)
    return loop


async def main():
    async with asyncio.TaskGroup() as tg:
        async def third_task():
            raise RuntimeError("third task failed")

        async def second_task():
            tg.create_task(third_task())
            await asyncio.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

@graingert graingert added type-bug An unexpected behavior, bug, or error topic-asyncio labels Jan 6, 2025
@github-project-automation github-project-automation bot moved this to Todo in asyncio Jan 6, 2025
@picnixz picnixz added the stdlib Python modules in the Lib dir label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-asyncio type-bug An unexpected behavior, bug, or error
Projects
Status: Todo
Development

No branches or pull requests

2 participants