additional logging in mqttsensor task cancel

This commit is contained in:
avollkopf 2023-03-25 18:35:17 +01:00
parent 6e066282c4
commit 62298ae844
2 changed files with 9 additions and 6 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.1.7.a10"
__version__ = "4.1.7.a11"
__codename__ = "Groundhog Day"

View file

@ -126,11 +126,14 @@ class MQTTSensor(CBPiSensor):
return dict(value=self.value)
async def on_stop(self):
if self.mqtt_task.done() is False:
if not self.mqtt_task.done():
logging.warning("Task not done -> cancelling")
self.mqtt_task.cancel()
try:
logging.warning("trying to call cancelled task")
await self.mqtt_task
except asyncio.CancelledError:
logging.warning("Task has been Cancelled")
pass