From: Benjamin Braatz Date: Mon, 13 May 2024 07:02:06 +0000 (+0200) Subject: Version 0.3.5: Catch connection drop in sending X-Git-Tag: v0.3.5 X-Git-Url: http://git.graph-it.com/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=graphit%2Fcontrolpi-wsclient.git Version 0.3.5: Catch connection drop in sending --- diff --git a/controlpi_plugins/wsclient.py b/controlpi_plugins/wsclient.py index cc88145..70acba6 100644 --- a/controlpi_plugins/wsclient.py +++ b/controlpi_plugins/wsclient.py @@ -182,7 +182,11 @@ class WSClient(BasePlugin): self._client, self.name) if translated_message is not None: json_message = json.dumps(translated_message) - await self._websocket.send(json_message) + try: + await self._websocket.send(json_message) + except Exception as e: + print(f"WSClient '{self.name}':" + f" Exception in websocket send: {e}") async def run(self) -> None: """Connect to wsserver and process messages from it.""" @@ -236,7 +240,8 @@ class WSClient(BasePlugin): assert isinstance(json_message, str) await self._send(json_message) except Exception as e: - print(f"WSClient '{self.name}': Exception in connection: {e}") + print(f"WSClient '{self.name}':" + f" Exception in websocket receive loop: {e}") self._websocket = None print(f"WSClient '{self.name}': Connection closed" f" to {self.conf['url']}.") diff --git a/setup.py b/setup.py index 9ef7c68..ff95fa6 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open("README.md", "r") as readme_file: setuptools.setup( name="controlpi-wsclient", - version="0.3.4", + version="0.3.5", author="Graph-IT GmbH", author_email="info@graph-it.com", description="ControlPi Plugin for Websocket Clients",