Small fixes

Handle more errors, and fix Client.stopListening
This commit is contained in:
Mads Marquart
2020-01-05 20:29:44 +01:00
parent e488f4a7da
commit bc1e3edf17
2 changed files with 12 additions and 3 deletions

View File

@@ -2834,10 +2834,13 @@ class Client(object):
def stopListening(self):
"""Stop the listening loop."""
if not self._mqtt:
raise ValueError("Not listening")
self._mqtt.disconnect()
self.listening = False
if not self._mqtt:
return
self._mqtt.disconnect()
# TODO: Preserve the _mqtt object
# Currently, there's some issues when disconnecting
self._mqtt = None
def listen(self, markAlive=None):
"""Initialize and runs the listening loop continually.