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
|
return self._connecting_task is not None
|
||||||
|
|
||||||
def is_connected(self):
|
def is_connected(self):
|
||||||
return self._reader is not None
|
return self._writer is not None
|
||||||
|
|
||||||
async def disconnect(self):
|
async def disconnect(self):
|
||||||
if self._connecting_task is not None:
|
if self._connecting_task is not None:
|
||||||
|
@ -31,6 +31,10 @@ class Client:
|
||||||
self._connecting_task = None
|
self._connecting_task = None
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self._writer is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Reader needn't be closed
|
||||||
self._writer.close()
|
self._writer.close()
|
||||||
await self._writer.wait_closed()
|
await self._writer.wait_closed()
|
||||||
self._reader = None
|
self._reader = None
|
||||||
|
|
|
@ -156,10 +156,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||||
|
|
||||||
@asyncClose
|
@asyncClose
|
||||||
async def closeEvent(self, event):
|
async def closeEvent(self, event):
|
||||||
if self.client_watcher.is_watching():
|
self.client_watcher.stop_watching()
|
||||||
self.client_watcher.stop_watching()
|
await self.tec_client.disconnect()
|
||||||
if self.tec_client.is_connecting() or self.tec_client.is_connected():
|
|
||||||
await self.tec_client.disconnect()
|
|
||||||
|
|
||||||
@asyncSlot()
|
@asyncSlot()
|
||||||
async def connect(self):
|
async def connect(self):
|
||||||
|
|
Loading…
Reference in New Issue