Graceful shutdown of websockets #1137
Unanswered
aviramha
asked this question in
Potential Issue
Replies: 1 comment
-
iirc I added this while working on making pytest stricter #929 and specifically the ws addition you mention I was unsure about, see this comment for further context. so I'd be ok seeing a PR that removes that, but we just need to be sure that :
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
We've encountered a situation where Kubernetes terminates a pod, and Websocket connections aren't gracefully shutdown.
I debugged it a bit, and found out how Uvicorn behaves on termination - on simple HTTP - it just cancels the keep alive then awaits the server tasks.
On the websocket, it closes the transport on currently "running" websockets.
I want to suggest changing this behavior to only stop serving new connections, without shutting down the connections.
The code change would be just removing the
transport.close
on each websocket implementations, leaving the server.py code to await pending tasks, and canceling those if needed.Let me know if I can send a PR to apply this change.
Beta Was this translation helpful? Give feedback.
All reactions