Don't propagate the message from MQTT nor wait for a response if the message is null or its handler threw an exception

This commit is contained in:
Fabio Manganiello 2018-11-10 01:16:32 +01:00
parent cda64865f3
commit 2d8078b8bb

View file

@ -108,6 +108,7 @@ class MqttBackend(Backend):
msg = msg.payload.decode('utf-8')
try: msg = Message.build(json.loads(msg))
except: pass
if not msg: return
self.logger.info('Received message on the MQTT backend: {}'.format(msg))
@ -115,6 +116,7 @@ class MqttBackend(Backend):
self.on_message(msg)
except Exception as e:
self.logger.exception(e)
return
if isinstance(msg, Request):
threading.Thread(target=response_thread, args=(msg,)).start()