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" __codename__ = "Groundhog Day"

View file

@ -126,12 +126,15 @@ class MQTTSensor(CBPiSensor):
return dict(value=self.value) return dict(value=self.value)
async def on_stop(self): 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() self.mqtt_task.cancel()
try: try:
await self.mqtt_task logging.warning("trying to call cancelled task")
except asyncio.CancelledError: await self.mqtt_task
pass except asyncio.CancelledError:
logging.warning("Task has been Cancelled")
pass
def setup(cbpi): def setup(cbpi):