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

avoid collapsing exception groups from user code #2830

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

graingert
Copy link
Member

@graingert graingert commented Dec 29, 2024

Summary

If user code is raising ExceptionGroups eg from TaskGroups or otherwise, they should get ExceptionGroups raised. There could also be important notes attached.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

No docs changes needed, probably should have made an issue for this.

tests/test__utils.py Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
@graingert graingert requested a review from Kludex December 30, 2024 08:29
@@ -258,7 +259,7 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
except OSError:
raise ClientDisconnect()
else:
async with anyio.create_task_group() as task_group:
async with create_collapsing_task_group() as task_group:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also have an issue with StreamingResponse standalone?

With my comment on the other PR I was trying to avoid the changes here. 🤔

Copy link
Member Author

@graingert graingert Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's the same sort of issue, but it's wrapped in two TaskGroups before the user gets the exception. Collapsing is ok here because if wait_for_disconnect raises an exception it is always 'catastrophic' eg won't be caught

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants