From 1a321b471251717604ef352112d221e74e6a89d7 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Sat, 5 Feb 2022 11:08:49 +0100 Subject: [PATCH] error handling improved --- opcua2mqtt/MqttPublish.py | 5 ++--- opcua2mqtt/OpcUaRequester.py | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/opcua2mqtt/MqttPublish.py b/opcua2mqtt/MqttPublish.py index 3714901..746383e 100644 --- a/opcua2mqtt/MqttPublish.py +++ b/opcua2mqtt/MqttPublish.py @@ -35,9 +35,8 @@ class MqttPublish(AbstractMqttPublisher): payload = { "count": cnt, "uptime": uptime } self.client.publish(self.statusTopic, json.dumps(payload), retain=True) except Empty: - if self.killBill: - logger.error("killbill received") - break + # just evaluate the killBill at the top of the loop again + pass except Exception as e: logger.error(f"Exception {type(e)} received in MQTT local loop: {e}") diff --git a/opcua2mqtt/OpcUaRequester.py b/opcua2mqtt/OpcUaRequester.py index d333652..49dd62f 100644 --- a/opcua2mqtt/OpcUaRequester.py +++ b/opcua2mqtt/OpcUaRequester.py @@ -38,8 +38,10 @@ class OpcUaRequester(threading.Thread): except ua.UaError as e: logger.error(f"UaError in inner OPC-UA loop: {type(e)} {e}") await asyncio.sleep(self.delay) - except TimeoutError as e: + except asyncio.exceptions.TimeoutError as e: logger.error(f"Timeout in inner OPC-UA loop") + except Exception as e: + logger.error(f"Exception in inner OPC-UA loop: {type(e)} {e}") def run(self): loop = asyncio.new_event_loop()