From daa3192d41580c8bc5ea27913c1655863dfa8ce8 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..31f02e9 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() + self.handle_connection_error() return self._update_params_task = asyncio.create_task(self.update_params()) await asyncio.sleep(self._update_s) + def handle_connection_error(self): + 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 72b4304..fa072d5 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -76,7 +76,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) async def autotune_disconnect():