cancelling also mqtt listening on cacnellederror

This commit is contained in:
avollkopf 2023-03-26 11:36:18 +02:00
parent 3768a77dfe
commit b0406a4de8
2 changed files with 6 additions and 2 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.1.7.a13" __version__ = "4.1.7.a14"
__codename__ = "Groundhog Day" __codename__ = "Groundhog Day"

View file

@ -70,6 +70,10 @@ class SatelliteController:
method = topic_filter[1] method = topic_filter[1]
if message.topic.matches(topic): if message.topic.matches(topic):
await (method(message)) await (method(message))
except asyncio.CancelledError:
# Cancel
self.logger.warning("MQTT Listening Cancelled")
break
except MqttError as e: except MqttError as e:
self.logger.error("MQTT Exception: {}".format(e)) self.logger.error("MQTT Exception: {}".format(e))
except Exception as e: except Exception as e:
@ -164,7 +168,7 @@ class SatelliteController:
await method(message.payload.decode()) await method(message.payload.decode())
except asyncio.CancelledError: except asyncio.CancelledError:
# Cancel # Cancel
self.logger.warning("Sub Cancelled") self.logger.warning("Subscription {} Cancelled".format(topic))
self.error=True self.error=True
except MqttError as e: except MqttError as e:
self.logger.error("Sub MQTT Exception: {}".format(e)) self.logger.error("Sub MQTT Exception: {}".format(e))