diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index cc98c4d..329ffb3 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -259,19 +259,17 @@ class MainWindow(QtWidgets.QMainWindow): ) try: await self._connecting_task - except (OSError, asyncio.TimeoutError): + except (OSError, asyncio.TimeoutError, asyncio.CancelledError): await self.bail() return - except asyncio.CancelledError: - return else: await self._on_connection_changed(True) finally: self._connecting_task = None + elif self._connecting_task is not None: + self._connecting_task.cancel() else: - if self._connecting_task is not None: - self._connecting_task.cancel() await self.bail() @asyncSlot()