From ca0c4e30890a05c87c7fe497165c1018ed2729f8 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 27 Aug 2020 16:59:35 +0200 Subject: [PATCH] Don't overwrite the client variable within the same scope --- platypush/backend/mqtt.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/platypush/backend/mqtt.py b/platypush/backend/mqtt.py index 1b2e787460..14c68b71ad 100644 --- a/platypush/backend/mqtt.py +++ b/platypush/backend/mqtt.py @@ -144,10 +144,9 @@ class MqttBackend(Backend): def _initialize_listeners(self, listeners_conf): import paho.mqtt.client as mqtt - # noinspection PyShadowingNames - def listener_thread(client, host, port): - client.connect(host, port) - client.loop_forever() + def listener_thread(client_, host, port): + client_.connect(host, port) + client_.loop_forever() # noinspection PyShadowingNames,PyUnusedLocal for i, listener in enumerate(listeners_conf): @@ -181,7 +180,7 @@ class MqttBackend(Backend): client.tls_insecure_set(self.tls_insecure) threading.Thread(target=listener_thread, kwargs={ - 'client': client, 'host': host, 'port': port}).start() + 'client_': client, 'host': host, 'port': port}).start() def on_exec_message(self): def handler(_, __, msg):