Skip to content

AttributeError: 'TaskGroup' object has no attribute '_exceptions' #1109

Closed

Description

@leon1995

Things to check first

  • I have searched the existing issues and didn't find my bug already reported there

  • I have checked that my bug is still present in the latest release

AnyIO version

4.13.0

Python version

3.13.3

What happened?

Entering the context of a task group multiple times raises an AttributeError

Traceback (most recent call last):
  File "...\.venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 794, in __aexit__
    if self._exceptions:
       ^^^^^^^^^^^^^^^^
AttributeError: 'TaskGroup' object has no attribute '_exceptions'

I suggest to raise a different exception if this behavior is not intended

How can we reproduce the bug?

async def reproduce():
    tg = anyio.create_task_group()
    async with tg:
        print(1)
    async with tg:
        print(2)
    async with tg:
        print(3)


anyio.run(reproduce)

outputs

1
2
Traceback (most recent call last): ...

Activity

  1. added a commit that references this issue on Apr 14, 2026
    4dfe21a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions