diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2023-01-01 18:48:50 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2023-01-01 18:48:50 +0300 |
commit | eb2ab011986cc93d35b817fd867821e6e205f194 (patch) | |
tree | a1e81dac8cb455aabbdf6b619f12d51c6cc2dae2 /src | |
parent | e49fdedb40e0ea7dc1d67ff081b5c19718d92565 (diff) |
mqtt_relay_util: exit gracefully on ctrl+c
Diffstat (limited to 'src')
-rwxr-xr-x | src/relay_mqtt_util.py | 5 |
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() |