From a370abf4108e513cfc822e1617749d32862a5c7d Mon Sep 17 00:00:00 2001
From: bwduncan <bwduncan@gmail.com>
Date: Fri, 20 Oct 2017 09:57:24 +0100
Subject: [PATCH] Fix MQTT loop thread crash. (remove on_disconnect) (#21)

---
 pi_mqtt_gpio/server.py | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/pi_mqtt_gpio/server.py b/pi_mqtt_gpio/server.py
index eaa458c..0caed5f 100644
--- a/pi_mqtt_gpio/server.py
+++ b/pi_mqtt_gpio/server.py
@@ -77,22 +77,6 @@ class ConfigValidator(cerberus.Validator):
         return str(value)
 
 
-def on_disconnect(client, userdata, rc):
-    """
-    Called when MQTT client disconnects. Attempts to reconnect indefinitely
-    if disconnection was unintentional.
-    :param client: MQTT client instance
-    :param userdata: Any user data set in client
-    :param rc: The disconnection result (0 is intentional disconnect)
-    :return: None
-    :rtype: NoneType
-    """
-    _LOG.warning("Disconnected from MQTT server with code: %s" % rc)
-    while rc != 0:
-        sleep(RECONNECT_DELAY_SECS)
-        rc = client.reconnect()
-
-
 def on_log(client, userdata, level, buf):
     """
     Called when MQTT client wishes to log something.
@@ -364,7 +348,6 @@ def init_mqtt(config, digital_outputs):
         except Exception:
             _LOG.exception("Exception while handling received MQTT message:")
 
-    client.on_disconnect = on_disconnect
     client.on_connect = on_conn
     client.on_message = on_msg
     client.on_log = on_log
-- 
GitLab