From 89968d374d03a3a467221f488596297745756302 Mon Sep 17 00:00:00 2001 From: Benjamin Braatz Date: Wed, 19 May 2021 05:58:28 +0200 Subject: [PATCH] Simplify connection closed exception. --- controlpi_plugins/wsserver.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/controlpi_plugins/wsserver.py b/controlpi_plugins/wsserver.py index fc7a3fe..2a79b8c 100644 --- a/controlpi_plugins/wsserver.py +++ b/controlpi_plugins/wsserver.py @@ -10,8 +10,7 @@ TODO: Let clients filter messages received over websocket import os import sys import json -from websockets import (WebSocketServerProtocol, ConnectionClosedOK, - ConnectionClosedError, serve) +from websockets import WebSocketServerProtocol, ConnectionClosed, serve from websockets.http import Headers from http import HTTPStatus @@ -63,7 +62,7 @@ class Connection: message = {'sender': self._name} message.update(original_message) await self._bus.send(message) - except (ConnectionClosedOK, ConnectionClosedError): + except ConnectionClosed: pass await self._bus.send({'sender': self._name, 'event': 'connection closed'}) -- 2.34.1