mstar.api_server.streaming_response#
A streaming response that cleans up after a body Starlette never started.
Classes
|
A |
- class mstar.api_server.streaming_response.ReleasingStreamingResponse(content, *, release, **kwargs)[source]#
Bases:
StreamingResponseA
StreamingResponsethat callsreleasewhen its body never started.Starlette sends the headers before it iterates the body, and leaves the body unstarted when that send raises: uvicorn 0.28.0 (the release that reports ASGI 2.4) raises from
sendonce the client has left. A server that cancels the response before its first step would do the same; current uvicorn does neither, so there the body starts and aborts the request itself, and this is a guard. An async generator that never started never runs itsfinally, so what the body releases on an early exit (its engine request, read-ahead pieces, uploaded files) would be held until the process restarts.- Parameters:
content (AsyncGenerator)
release (Callable[[], None])