From 2334a922f74db2095bc39f4c1a3967d56720fee5 Mon Sep 17 00:00:00 2001 From: atse Date: Mon, 9 Sep 2024 11:42:12 +0800 Subject: [PATCH] Remove error handling for connecting task Just let the exception propagate, even when stopping the connection --- pytec/tec_qt.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index e5267f0..ba67911 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -191,21 +191,15 @@ class MainWindow(QtWidgets.QMainWindow): ) ) self.thermostat.connection_state = ThermostatConnectionState.CONNECTING - try: - await self._connecting_task - except (OSError, asyncio.CancelledError) as exc: - await self.thermostat.end_session() - if isinstance(exc, asyncio.CancelledError): - return - raise - finally: - self._connecting_task = None + await self._connecting_task + self._connecting_task = None self.thermostat.connection_state = ThermostatConnectionState.CONNECTED self.thermostat.start_watching() case ThermostatConnectionState.CONNECTING: self._connecting_task.cancel() - self.thermostat.connection_state = ( + await self._thermostat.end_session() + self._thermostat.connection_state = ( ThermostatConnectionState.DISCONNECTED ) self._connecting_task = None