From b11ee7fe43f9b09f4ed1a1ab38be53275a811a23 Mon Sep 17 00:00:00 2001 From: Helldog136 Date: Sun, 15 May 2022 23:58:51 +0200 Subject: [PATCH] #50 : Fix potential AttributeError for new configurations in case of mqtt error --- tuya_iot/openmq.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tuya_iot/openmq.py b/tuya_iot/openmq.py index 07936e0..3573c4f 100644 --- a/tuya_iot/openmq.py +++ b/tuya_iot/openmq.py @@ -160,7 +160,6 @@ def run(self): try: self.__run_mqtt() backoff_seconds = 1 - # reconnect every 2 hours required. time.sleep(self.mq_config.expire_time - 60) except RequestException as e: @@ -175,6 +174,8 @@ def __run_mqtt(self): mq_config = self._get_mqtt_config() if mq_config is None: logger.error("error while get mqtt config") + if self.mq_config is None: # if we have no initial mq_config this is a big problem. + raise RequestException() return self.mq_config = mq_config