@@ -120,14 +120,10 @@ that runs for each request. When it returns an HTTP response, websockets sends
120
120
that response instead of opening a WebSocket connection. Here, requests to
121
121
``/healthz `` return an HTTP 200 status code.
122
122
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.
131
127
132
128
Deploy the WebSocket server
133
129
---------------------------
@@ -157,14 +153,14 @@ Commit and push your changes:
157
153
158
154
$ git add .
159
155
$ 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(-)
162
158
create mode 100644 Procfile
163
159
create mode 100644 requirements.txt
164
160
$ git push
165
161
...
166
162
To github.com:python-websockets/websockets-tutorial.git
167
- + 6bd6032...ac96d65 main -> main
163
+ + 6bd6032...4a4b6e9 main -> main
168
164
169
165
Sign up or log in to Koyeb.
170
166
@@ -239,7 +235,7 @@ Commit your changes:
239
235
$ git push
240
236
...
241
237
To github.com:python-websockets/websockets-tutorial.git
242
- + ac96d65 ...0903526 main -> main
238
+ + 4a4b6e9 ...968eaaa main -> main
243
239
244
240
Deploy the web application
245
241
--------------------------
0 commit comments