From cbe321e1aa2aed2b9dfac6bf99f4c7a21632de2d Mon Sep 17 00:00:00 2001 From: Marcin Kaptur Date: Sun, 6 Nov 2022 13:59:13 +0100 Subject: [PATCH] Loop handling --- MQTTClient.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/MQTTClient.py b/MQTTClient.py index 0fe5c3c..74e38fc 100644 --- a/MQTTClient.py +++ b/MQTTClient.py @@ -106,11 +106,10 @@ def run(self): self.logger.error('Reconnecting, try:%s' % (self.connect_retry_counter+1)) self.connect(self.config) self.connect_retry_counter += 1 + if not self.__messageQ.empty(): + task = self.__messageQ.get() + if task['method'] == 'publish': + self.publish(task) else: - if not self.__messageQ.empty(): - task = self.__messageQ.get() - if task['method'] == 'publish': - self.publish(task) - else: - time.sleep(0.1) + time.sleep(0.1) self._mqttConn.loop()