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's task's exception's participate in a reference cycle, via TaskGroup.create_task -> task -> exception and loop.create_task -> task -> exception #128552

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:

the following test fails when run with eager tasks

    async def test_exception_refcycles_parent_task(self):
        """Test that TaskGroup deletes self._parent_task"""
        tg = asyncio.TaskGroup()
        exc = None

        class _Done(Exception):
            pass

        async def coro_fn():
            async with tg:
                raise _Done

        try:
            async with asyncio.TaskGroup() as tg2:
                tg2.create_task(coro_fn())
        except* _Done as excs:
            exc = excs.exceptions[0].exceptions[0]

        self.assertIsInstance(exc, _Done)
        self.assertListEqual(gc.get_referrers(exc), no_other_refs())

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs

@graingert graingert added the type-bug An unexpected behavior, bug, or error label Jan 6, 2025
graingert added a commit to graingert/cpython that referenced this issue Jan 6, 2025
graingert added a commit to graingert/cpython that referenced this issue 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
graingert added a commit to graingert/cpython that referenced this issue Jan 7, 2025
kumaraditya303 pushed a commit that referenced this issue Jan 8, 2025
…8585)

gh-128552: fix refcycles in eager task creation (#128553)

(cherry picked from commit 61b9811)
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