summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2023-01-01 18:48:50 +0300
committerEvgeny Zinoviev <me@ch1p.io>2023-01-01 18:48:50 +0300
commiteb2ab011986cc93d35b817fd867821e6e205f194 (patch)
treea1e81dac8cb455aabbdf6b619f12d51c6cc2dae2
parente49fdedb40e0ea7dc1d67ff081b5c19718d92565 (diff)
mqtt_relay_util: exit gracefully on ctrl+c
-rwxr-xr-xsrc/relay_mqtt_util.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/relay_mqtt_util.py b/src/relay_mqtt_util.py
index 29a0532..45d2405 100755
--- a/src/relay_mqtt_util.py
+++ b/src/relay_mqtt_util.py
@@ -39,4 +39,7 @@ if __name__ == '__main__':
mqtt_relay = MQTTRelay(devices=MQTTRelayDevice(id=arg.device_id))
mqtt_relay.set_message_callback(on_mqtt_message)
mqtt_relay.configure_tls()
- mqtt_relay.connect_and_loop()
+ try:
+ mqtt_relay.connect_and_loop()
+ except KeyboardInterrupt:
+ mqtt_relay.disconnect()