From e670451977e270172100ea2a39d31d73623be9c8 Mon Sep 17 00:00:00 2001 From: zewelor Date: Thu, 18 Jan 2018 08:40:52 +0100 Subject: [PATCH] Add timeouts per thermostat device --- workers/thermostat.py | 7 ++++++- workers_manager.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/workers/thermostat.py b/workers/thermostat.py index fd8a28b..ca5261d 100644 --- a/workers/thermostat.py +++ b/workers/thermostat.py @@ -1,5 +1,6 @@ from builtins import staticmethod +from interruptingcow import timeout from mqtt import MqttMessage from workers.base import BaseWorker @@ -61,7 +62,10 @@ class ThermostatWorker(BaseWorker): def status_update(self): ret = [] for name, thermostat in self.devices.items(): - ret += self.update_device_state(name, thermostat) + try: + ret += self.update_device_state(name, thermostat) + except RuntimeError: + pass return ret @@ -84,6 +88,7 @@ class ThermostatWorker(BaseWorker): setattr(thermostat, method, value) return self.update_device_state(device_name, thermostat) + @timeout(8.0) def update_device_state(self, name, thermostat): thermostat.update() diff --git a/workers_manager.py b/workers_manager.py index 09080d4..98df8aa 100644 --- a/workers_manager.py +++ b/workers_manager.py @@ -16,7 +16,7 @@ class WorkersManager: def execute(self): messages = [] - with timeout(30): + with timeout(35): messages = self._callback(*self._args) _LOGGER.debug(messages)