-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebSocketServer.run() docs and shutdown #161
Comments
Ah, it looks like the server is returned via "When called by nursery.start(serve_websocket, ...) instead of nursery.start_soon, the running instance of WebSocketServer is returned." |
With |
(I changed the title to Here are the current docs with more context:
It does say that return of the Note that Trio library functions like
Trio has cancel scopes, and API implementations are able to encapsulate both synchronous and asynchronous shutdown. So the way you'd shut down the websocket server is to cancel the parent task. Note that there are two potential cancel points: async with trio.open_nursery() as nursery:
# cancel if it takes more than 1 second to start accepting connections
with trio.fail_after(1):
await nursery.start(partial(serve_websocket, ...))
# sorry, this server will self-destruct after 5 minutes
await trio.sleep(5 * 60)
nursery.cancel_scope.cancel() Everything should be cleanly shut down under such cancellations (as well as by Ctrl-C and SIGTERM)-- is there evidence otherwise? |
These cannot both be true. The second remark matches the implementation, but the first remark is preferred. Currently, there doesn't seem to be a good way to cleanly shut down the server.
The text was updated successfully, but these errors were encountered: