From 34d142c87af2782be67af85e7d74a702bcf7466e Mon Sep 17 00:00:00 2001 From: Nathaniel Walizer Date: Mon, 5 Sep 2022 09:04:59 -0700 Subject: [PATCH] Fix crash on bad MQTT config --- blinky.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/blinky.py b/blinky.py index d473737..14f1519 100755 --- a/blinky.py +++ b/blinky.py @@ -28,7 +28,7 @@ def file_thread(file): def process_IN_CLOSE_WRITE(self, event): global reload, config with lock_reload: - print("Triggering reload") + print("Triggering file reload") config = None reload = True cond_reload.notify_all() @@ -54,9 +54,13 @@ def mqtt_thread(): def on_message(client, userdata, message): global reload, config 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)