3 ms·
>But Flask does not give control of what happens when the client suddenly closes the connection. It is so annoying that they don't give you a way to do this. I
by cyberes 2y ago
>But Flask does not give control of what happens when the client suddenly closes the connection.
It is so annoying that they don't give you a way to do this. I built an LLM inference API but am still working on how to cancel an inference job if a client cancels. I really don't want to rewrite my entire server in Twisted so I'll probably end up just building the HTTP responses like you did.
- michielderhaeg 2y agoFlask is FOSS, maybe it is not too difficult to add support for this yourselves.
- nicolaslem 2y agoI believe the WSGI spec is a bit unclear on this but some WSGI servers can give back control to the app when the connection gets closed. I use Flask and Waitress for long-lived server side events and my app is notified when the client closes the connection before the end of the stream of events.
- rahimnathwani 2y agoCan you not use teardown_request to run some clean up code after each request?