Commits

Roger Light committed c670919

Don't fail reconnecting in Python when broker is temporarily unavailable.

  • Participants
  • Parent commits 952239b
  • Branches 1.2.1

Comments (0)

Files changed (3)

File ChangeLog.txt

 - Fix TLS subjectAltName verification and segfaults.
 - Handle EAGAIN in Python on Windows. Closes bug #1220004.
 - Fix compilation when using WITH_TLS=no.
+- Don't fail reconnecting in Python when broker is temporarily unavailable.
 
 1.2 - 20130708
 ==============

File lib/python/mosquitto.py

                     self._state_mutex.release()
                 else:
                     self._state_mutex.release()
-                    self.reconnect()
+                    try:
+                        self.reconnect()
+                    except socket.error as err:
+                        pass
         return rc
 
     def loop_start(self):

File lib/python/sub.py

 import mosquitto
 
 def on_connect(mosq, obj, rc):
+    mosq.subscribe("$SYS/#", 0)
     print("rc: "+str(rc))
 
 def on_message(mosq, obj, msg):
 # Uncomment to enable debug messages
 #mqttc.on_log = on_log
 mqttc.connect("test.mosquitto.org", 1883, 60)
-mqttc.subscribe("$SYS/#", 0)
 
 
-rc = 0
-while rc == 0:
-    rc = mqttc.loop()
+mqttc.loop_forever()
 
-print("rc: "+str(rc))