Catch CancelledError for connections.
authorBenjamin Braatz <bb@bbraatz.eu>
Thu, 29 Jul 2021 22:17:31 +0000 (00:17 +0200)
committerBenjamin Braatz <bb@bbraatz.eu>
Thu, 29 Jul 2021 22:17:31 +0000 (00:17 +0200)
controlpi_plugins/wsserver.py

index 7d38a084e96df1dd2e895b85c65c32585d547f8f..981f7e2128a2605b071ac32580d6bee460cd544c 100644 (file)
@@ -126,7 +126,10 @@ class WSServer(BasePlugin):
     async def _handler(self, websocket: WebSocketServerProtocol,
                        path: str) -> None:
         connection = Connection(self.bus, websocket)
-        await connection.run()
+        try:
+            await connection.run()
+        except asyncio.CancelledError:
+            pass
 
     async def _process_request(self, path: str,
                                request_headers: Headers) -> Response: