forked from M-Labs/thermostat
parent
ae9c34f411
commit
bc4b5bb615
|
@ -557,8 +557,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||||
|
|
||||||
@asyncClose
|
@asyncClose
|
||||||
async def closeEvent(self, event):
|
async def closeEvent(self, event):
|
||||||
await self._on_connection_changed(False)
|
await self.bail()
|
||||||
await self.client.disconnect()
|
|
||||||
|
|
||||||
@asyncSlot()
|
@asyncSlot()
|
||||||
async def on_connect_btn_clicked(self):
|
async def on_connect_btn_clicked(self):
|
||||||
|
@ -576,11 +575,13 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||||
return
|
return
|
||||||
await self._on_connection_changed(True)
|
await self._on_connection_changed(True)
|
||||||
else:
|
else:
|
||||||
await self._on_connection_changed(False)
|
await self.bail()
|
||||||
await self.client.disconnect()
|
|
||||||
|
|
||||||
except (OSError, TimeoutError, asyncio.TimeoutError) as e: # TODO: Remove asyncio.TimeoutError in Python 3.11
|
except (OSError, TimeoutError, asyncio.TimeoutError) as e: # TODO: Remove asyncio.TimeoutError in Python 3.11
|
||||||
logging.error(f"Failed communicating to {host}:{port}: {e}")
|
logging.error(f"Failed communicating to {host}:{port}: {e}")
|
||||||
|
await self.bail()
|
||||||
|
|
||||||
|
async def bail(self):
|
||||||
await self._on_connection_changed(False)
|
await self._on_connection_changed(False)
|
||||||
await self.client.disconnect()
|
await self.client.disconnect()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue