@@ -120,14 +120,10 @@ that runs for each request. When it returns an HTTP response, websockets sends
120120that response instead of opening a WebSocket connection. Here, requests to
121121``/healthz `` return an HTTP 200 status code.
122122
123- To catch the ``SIGTERM `` signal, ``main() `` creates a :class: `~asyncio.Future `
124- called ``stop `` and registers a signal handler that sets the result of this
125- future. The value of the future doesn't matter; it's only for waiting for
126- ``SIGTERM ``.
127-
128- Then, by using :func: `~asyncio.server.serve ` as a context manager and exiting
129- the context when ``stop `` has a result, ``main() `` ensures that the server
130- closes connections cleanly and exits on ``SIGTERM ``.
123+ ``main() `` registers a signal handler that closes the server when receiving the
124+ ``SIGTERM `` signal. Then, it waits for the server to be closed. Additionally,
125+ using :func: `~asyncio.server.serve ` as a context manager ensures that the server
126+ will always be closed cleanly, even if the program crashes.
131127
132128Deploy the WebSocket server
133129---------------------------
@@ -157,14 +153,14 @@ Commit and push your changes:
157153
158154 $ git add .
159155 $ git commit -m "Deploy to Koyeb."
160- [main ac96d65 ] Deploy to Koyeb.
161- 3 files changed, 18 insertions(+), 2 deletions(-)
156+ [main 4a4b6e9 ] Deploy to Koyeb.
157+ 3 files changed, 15 insertions(+), 2 deletions(-)
162158 create mode 100644 Procfile
163159 create mode 100644 requirements.txt
164160 $ git push
165161 ...
166162 To github.com:python-websockets/websockets-tutorial.git
167- + 6bd6032...ac96d65 main -> main
163+ + 6bd6032...4a4b6e9 main -> main
168164
169165 Sign up or log in to Koyeb.
170166
@@ -239,7 +235,7 @@ Commit your changes:
239235 $ git push
240236 ...
241237 To github.com:python-websockets/websockets-tutorial.git
242- + ac96d65 ...0903526 main -> main
238+ + 4a4b6e9 ...968eaaa main -> main
243239
244240 Deploy the web application
245241--------------------------
0 commit comments