You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current streaming response API requires returning an async generator. This is really awkward to use given that so many async classes are not RAII - initialised with __init__ and finalised with __del__ - but are async context managers, initialised with __aenter__ and finalised with __aexit__.
For example, to use httpx's streaming responses in a quart streaming response, I came up with this abomination:
I don't think this is necessarily right because if the iter_response generator is discarded because the remote client hangs up, then maybe? GeneratorExit is raised but I doubt that there is a task that would actually run the await in the finally block.
Plain ASGI doesn't have this problem: you can just wrap async context managers around a bunch of
The current streaming response API requires returning an async generator. This is really awkward to use given that so many async classes are not RAII - initialised with
__init__
and finalised with__del__
- but are async context managers, initialised with__aenter__
and finalised with__aexit__
.For example, to use httpx's streaming responses in a quart streaming response, I came up with this abomination:
I don't think this is necessarily right because if the iter_response generator is discarded because the remote client hangs up, then maybe? GeneratorExit is raised but I doubt that there is a task that would actually run the
await
in thefinally
block.Plain ASGI doesn't have this problem: you can just wrap async context managers around a bunch of
so
I would propose an API in Quart that allows this, e.g.
The text was updated successfully, but these errors were encountered: