Browse Source

Fix crash on bad MQTT config

master
Nathaniel Walizer 3 years ago
parent
commit
34d142c87a
1 changed files with 8 additions and 4 deletions
  1. +8
    -4
      blinky.py

+ 8
- 4
blinky.py View File

@@ -28,7 +28,7 @@ def file_thread(file):
def process_IN_CLOSE_WRITE(self, event): def process_IN_CLOSE_WRITE(self, event):
global reload, config global reload, config
with lock_reload: with lock_reload:
print("Triggering reload")
print("Triggering file reload")
config = None config = None
reload = True reload = True
cond_reload.notify_all() cond_reload.notify_all()
@@ -54,9 +54,13 @@ def mqtt_thread():
def on_message(client, userdata, message): def on_message(client, userdata, message):
global reload, config global reload, config
with lock_reload: with lock_reload:
config = json.loads(message.payload)
reload = True
cond_reload.notify_all()
print("Triggering MQTT reload")
try:
config = json.loads(message.payload)
reload = True
cond_reload.notify_all()
except:
print("Invalid MQTT config")


subscribe.callback(on_message, mqtt.topic, hostname=mqtt.hostname, auth=mqtt.auth, port=8883, tls=mqtt.tls) subscribe.callback(on_message, mqtt.topic, hostname=mqtt.hostname, auth=mqtt.auth, port=8883, tls=mqtt.tls)




Loading…
Cancel
Save