added soome additional info on cancelled task

This commit is contained in:
avollkopf 2023-03-25 19:15:26 +01:00
parent bcf9b3e06b
commit 3768a77dfe
3 changed files with 12 additions and 8 deletions

View file

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

View file

@ -153,6 +153,7 @@ class SatelliteController:
return task
async def _subcribe(self, topic, method):
self.error=False
while True:
try:
if self.client._connected.done():
@ -164,10 +165,13 @@ class SatelliteController:
except asyncio.CancelledError:
# Cancel
self.logger.warning("Sub Cancelled")
break
self.error=True
except MqttError as e:
self.logger.error("Sub MQTT Exception: {}".format(e))
except Exception as e:
self.logger.error("Sub Exception: {}".format(e))
# wait before try to resubscribe
if self.error == True:
break
else:
await asyncio.sleep(5)

View file

@ -127,15 +127,15 @@ class MQTTSensor(CBPiSensor):
async def on_stop(self):
if not self.mqtt_task.done():
logging.warning("Task not done -> cancelling")
self.mqtt_task.cancel()
logging.info("Task not done -> cancelling")
was_cancelled = self.mqtt_task.cancel()
try:
logging.warning("trying to call cancelled task")
logging.info("Trying to call cancelled task")
await self.mqtt_task
except asyncio.CancelledError:
logging.warning("Task has been Cancelled")
logging.info("Task has been Cancelled")
pass
logging.info("Task cancelled: {}".format(was_cancelled))
def setup(cbpi):
'''