From 671004703bc2d2f421768a108d0a96bf0159be26 Mon Sep 17 00:00:00 2001 From: atse Date: Thu, 29 Aug 2024 11:40:57 +0800 Subject: [PATCH] end_session in thermostat itself afterall --- pytec/pytec/gui/model/thermostat.py | 6 +++++- pytec/tec_qt.py | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pytec/pytec/gui/model/thermostat.py b/pytec/pytec/gui/model/thermostat.py index b0ee322..1480f8a 100644 --- a/pytec/pytec/gui/model/thermostat.py +++ b/pytec/pytec/gui/model/thermostat.py @@ -54,11 +54,15 @@ class Thermostat(QObject, metaclass=PropertyMeta): "Encountered an error while polling for information from Thermostat.", exc_info=True, ) - self.connection_error.emit() + await self.handle_connection_error() return self._update_params_task = asyncio.create_task(self.update_params()) await asyncio.sleep(self._update_s) + async def handle_connection_error(self): + await self.end_session() + self.connection_error.emit() + async def get_hw_rev(self): return await self._client.hw_rev() diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 8c5ab1a..a0baf79 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -80,7 +80,6 @@ class MainWindow(QtWidgets.QMainWindow): self.info_box.display_info_box( "Connection Error", "Thermostat connection lost. Is it unplugged?" ) - await self.thermostat.end_session() self.thermostat.connection_error.connect(handle_connection_error) # Control Panel