mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-25 00:18:17 +01:00
added soome additional info on cancelled task
This commit is contained in:
parent
bcf9b3e06b
commit
3768a77dfe
3 changed files with 12 additions and 8 deletions
|
@ -1,3 +1,3 @@
|
||||||
__version__ = "4.1.7.a12"
|
__version__ = "4.1.7.a13"
|
||||||
__codename__ = "Groundhog Day"
|
__codename__ = "Groundhog Day"
|
||||||
|
|
||||||
|
|
|
@ -153,6 +153,7 @@ class SatelliteController:
|
||||||
return task
|
return task
|
||||||
|
|
||||||
async def _subcribe(self, topic, method):
|
async def _subcribe(self, topic, method):
|
||||||
|
self.error=False
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
if self.client._connected.done():
|
if self.client._connected.done():
|
||||||
|
@ -164,10 +165,13 @@ class SatelliteController:
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
# Cancel
|
# Cancel
|
||||||
self.logger.warning("Sub Cancelled")
|
self.logger.warning("Sub Cancelled")
|
||||||
break
|
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))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error("Sub Exception: {}".format(e))
|
self.logger.error("Sub Exception: {}".format(e))
|
||||||
# wait before try to resubscribe
|
# wait before try to resubscribe
|
||||||
|
if self.error == True:
|
||||||
|
break
|
||||||
|
else:
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(5)
|
||||||
|
|
|
@ -127,15 +127,15 @@ class MQTTSensor(CBPiSensor):
|
||||||
|
|
||||||
async def on_stop(self):
|
async def on_stop(self):
|
||||||
if not self.mqtt_task.done():
|
if not self.mqtt_task.done():
|
||||||
logging.warning("Task not done -> cancelling")
|
logging.info("Task not done -> cancelling")
|
||||||
self.mqtt_task.cancel()
|
was_cancelled = self.mqtt_task.cancel()
|
||||||
try:
|
try:
|
||||||
logging.warning("trying to call cancelled task")
|
logging.info("Trying to call cancelled task")
|
||||||
await self.mqtt_task
|
await self.mqtt_task
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
logging.warning("Task has been Cancelled")
|
logging.info("Task has been Cancelled")
|
||||||
pass
|
pass
|
||||||
|
logging.info("Task cancelled: {}".format(was_cancelled))
|
||||||
|
|
||||||
def setup(cbpi):
|
def setup(cbpi):
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Reference in a new issue