From: Benjamin Braatz Date: Fri, 1 Jul 2022 10:19:47 +0000 (+0200) Subject: Catch BusException X-Git-Tag: v0.3.0~6 X-Git-Url: http://git.graph-it.com/?a=commitdiff_plain;h=ca8bdf54757dbb7127c6fcf43ad7765a42ff5aff;p=graphit%2Fcontrolpi-wsclient.git Catch BusException --- diff --git a/controlpi_plugins/wsclient.py b/controlpi_plugins/wsclient.py index c833c39..9dd4136 100644 --- a/controlpi_plugins/wsclient.py +++ b/controlpi_plugins/wsclient.py @@ -7,7 +7,7 @@ import struct from websockets.exceptions import ConnectionClosed, InvalidMessage from websockets.legacy.client import connect, WebSocketClientProtocol -from controlpi import BasePlugin, Message, MessageTemplate +from controlpi import BasePlugin, Message, MessageTemplate, BusException from typing import Optional, Dict, Any @@ -205,4 +205,7 @@ class WSClient(BasePlugin): translated_message = translate_message(message, self.name, self._client) if translated_message is not None: - await self.bus.send(Message(self.name, translated_message)) + try: + await self.bus.send(Message(self.name, translated_message)) + except BusException as e: + print(f"WSClient to {self.conf['url']}: {e}")