-
Notifications
You must be signed in to change notification settings - Fork 146
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
Reinstate "collapse exception group" in TaskGroup exception handling #641
Comments
First of all, Also, FastAPI doesn't even support AnyIO 4 yet, so how are you seeing this in FastAPI apps? |
Starlette supports AnyIO 4 and FastAPI seems to have no issues with it either. It makes sense for anyio to go in the same direction as the frameworks it builds upon and there are probably some good reasons for not collapsing exception groups. However, for the developing and monitoring (e.g. Sentry) experience it is such a step back that I resolved to patching the TaskGroup class. I guess the tooling still needs to grow around this. |
FastAPI pins Starlette to a version that doesn't have proper support for exception groups. I know this because I'm the one who patched Starlette to support AnyIO 4. Starlette 0.28 introduces a breaking change which FastAPI has not been able to adapt to yet, and as such, it has pinned AnyIO to |
I agree that the lack of tooling thus far to support exception groups is a bit frustrating. But then again, the very concept of exception groups is pretty novel in the entire field of programming AFAIK, and no other language has them yet. |
Ok, interesting. FYI this is the combination we run, and seems to work:
|
Well, just consider yourself warned that this is not a supported combination. At my day job we're probably switching to Litestar, as the relationship between FastAPI and Starlette is a constant source of trouble. |
Incidentally, I just saw this: python-trio/trio#2886 |
Saw the pingback to trio and just wanted to comment the reasoning as I understand it! Basically, this comes down to the fact that See https://discuss.python.org/t/flat-exception-groups-alternative-to-pep-654/10433#pep-654-3 for a more elaborate explanation of why we need to wrap everything in |
Things to check first
Feature description
First of all, many thanks for this excellent library.
The TaskGroup for the asyncio backend used a nice
collapse_exception_group()
function that keeps exception messages and stacktraces as clear as possible when only a single exception happens in a task group.It was removed in PR #586 and I wonder if it is possible to get that functionality back?
https://github.com/agronholm/anyio/pull/586/files#diff-202c3fc4551e5a287df488a9bd96a25dcc1405ec135d5c7aceb6ef4c02755341L678
Use case
The difference in readability of stacktraces between a single exception and an exception group is quite big. In Starlette/FastAPI for example the main exception messages have become "unhandled errors in a TaskGroup".
The text was updated successfully, but these errors were encountered: