This commit is contained in:
atse 2024-08-22 17:57:39 +08:00
parent 8ab93591a3
commit 6c09ce1be0
1 changed files with 7 additions and 9 deletions

View File

@ -41,15 +41,13 @@ class Thermostat(QObject, metaclass=PropertyMeta):
self._update_params_task = asyncio.create_task(self.update_params()) self._update_params_task = asyncio.create_task(self.update_params())
while True: while True:
if self._update_params_task.done(): if self._update_params_task.done():
if self._update_params_task.exception() is not None: try:
try: self._update_params_task.result()
raise self._update_params_task.exception() except asyncio.TimeoutError:
except asyncio.TimeoutError: logging.error(
logging.error( "Encountered an error while polling for information from Thermostat.",
"Encountered an error while polling for information from Thermostat.", exc_info=True,
exc_info=True, )
)
_ = self._update_params_task.result()
self._update_params_task = asyncio.create_task(self.update_params()) self._update_params_task = asyncio.create_task(self.update_params())
await asyncio.sleep(self._update_s) await asyncio.sleep(self._update_s)