Don't overwrite the client variable within the same scope

This commit is contained in:
Fabio Manganiello 2020-08-27 16:59:35 +02:00
parent beceb39b0c
commit ca0c4e3089

View file

@ -144,10 +144,9 @@ class MqttBackend(Backend):
def _initialize_listeners(self, listeners_conf): def _initialize_listeners(self, listeners_conf):
import paho.mqtt.client as mqtt import paho.mqtt.client as mqtt
# noinspection PyShadowingNames def listener_thread(client_, host, port):
def listener_thread(client, host, port): client_.connect(host, port)
client.connect(host, port) client_.loop_forever()
client.loop_forever()
# noinspection PyShadowingNames,PyUnusedLocal # noinspection PyShadowingNames,PyUnusedLocal
for i, listener in enumerate(listeners_conf): for i, listener in enumerate(listeners_conf):
@ -181,7 +180,7 @@ class MqttBackend(Backend):
client.tls_insecure_set(self.tls_insecure) client.tls_insecure_set(self.tls_insecure)
threading.Thread(target=listener_thread, kwargs={ 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 on_exec_message(self):
def handler(_, __, msg): def handler(_, __, msg):