forked from M-Labs/thermostat
No need to create a new task for waiting
This commit is contained in:
parent
3b2743c079
commit
2b02ea334a
@ -193,14 +193,12 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
async def on_connect_btn_clicked(self):
|
async def on_connect_btn_clicked(self):
|
||||||
match self._thermostat.connection_state:
|
match self._thermostat.connection_state:
|
||||||
case ThermostatConnectionState.DISCONNECTED:
|
case ThermostatConnectionState.DISCONNECTED:
|
||||||
self._connecting_task = asyncio.create_task(
|
self._connecting_task = asyncio.current_task()
|
||||||
self._thermostat.start_session(
|
|
||||||
host=self.connection_details_menu.host_set_line.text(),
|
|
||||||
port=self.connection_details_menu.port_set_spin.value(),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self._thermostat.connection_state = ThermostatConnectionState.CONNECTING
|
self._thermostat.connection_state = ThermostatConnectionState.CONNECTING
|
||||||
await self._connecting_task
|
await self._thermostat.start_session(
|
||||||
|
host=self.connection_details_menu.host_set_line.text(),
|
||||||
|
port=self.connection_details_menu.port_set_spin.value(),
|
||||||
|
)
|
||||||
self._connecting_task = None
|
self._connecting_task = None
|
||||||
self._thermostat.connection_state = ThermostatConnectionState.CONNECTED
|
self._thermostat.connection_state = ThermostatConnectionState.CONNECTED
|
||||||
self._thermostat.start_watching()
|
self._thermostat.start_watching()
|
||||||
|
Loading…
Reference in New Issue
Block a user