forked from M-Labs/thermostat
Simplify stuff a bit
This commit is contained in:
parent
e727f8b06b
commit
82438ee4a5
|
@ -23,7 +23,7 @@ class Client:
|
|||
return self._connecting_task is not None
|
||||
|
||||
def is_connected(self):
|
||||
return self._reader is not None
|
||||
return self._writer is not None
|
||||
|
||||
async def disconnect(self):
|
||||
if self._connecting_task is not None:
|
||||
|
@ -31,6 +31,10 @@ class Client:
|
|||
self._connecting_task = None
|
||||
return
|
||||
|
||||
if self._writer is None:
|
||||
return
|
||||
|
||||
# Reader needn't be closed
|
||||
self._writer.close()
|
||||
await self._writer.wait_closed()
|
||||
self._reader = None
|
||||
|
|
|
@ -156,10 +156,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||
|
||||
@asyncClose
|
||||
async def closeEvent(self, event):
|
||||
if self.client_watcher.is_watching():
|
||||
self.client_watcher.stop_watching()
|
||||
if self.tec_client.is_connecting() or self.tec_client.is_connected():
|
||||
await self.tec_client.disconnect()
|
||||
self.client_watcher.stop_watching()
|
||||
await self.tec_client.disconnect()
|
||||
|
||||
@asyncSlot()
|
||||
async def connect(self):
|
||||
|
|
Loading…
Reference in New Issue