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
Wondering if anyone has built a Response that "stalls" a JSON response, by using a streaming HTTP response that writes spaces, etc to the stream, until the full response is ready? The idea here would be to work around limitations in services like Heroku, which expect there to be response data written otherwise they close the connection. A similar proposal was made for Ruby: https://stackoverflow.com/a/38928195/2638485.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Wondering if anyone has built a
Response
that "stalls" a JSON response, by using a streaming HTTP response that writes spaces, etc to the stream, until the full response is ready? The idea here would be to work around limitations in services like Heroku, which expect there to be response data written otherwise they close the connection. A similar proposal was made for Ruby: https://stackoverflow.com/a/38928195/2638485.One idea would be to modify the
StreamingResponse
to have something like this: https://github.com/sysid/sse-starlette/blob/2d90414a452f29532a2c2e6fbc78f80563cad651/sse_starlette/sse.py#L239-L240 where a ping task (safely) writes the spaces until the json response is ready.Curious if that approach makes sense and / or if there are third party libraries that handle this already?
Beta Was this translation helpful? Give feedback.
All reactions