forked from M-Labs/thermostat
try-block
This commit is contained in:
parent
cebac565c4
commit
b0c30d128e
@ -252,20 +252,23 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
self.conn_menu.host_set_line.setEnabled(False)
|
self.conn_menu.host_set_line.setEnabled(False)
|
||||||
self.conn_menu.port_set_spin.setEnabled(False)
|
self.conn_menu.port_set_spin.setEnabled(False)
|
||||||
|
|
||||||
try:
|
|
||||||
self._connecting_task = asyncio.create_task(
|
self._connecting_task = asyncio.create_task(
|
||||||
asyncio.wait_for(self.thermostat.start_session(host=host, port=port), timeout=5)
|
asyncio.wait_for(
|
||||||
|
self.thermostat.start_session(host=host, port=port), timeout=5
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
try:
|
||||||
await self._connecting_task
|
await self._connecting_task
|
||||||
except (OSError, asyncio.TimeoutError):
|
except (OSError, asyncio.TimeoutError):
|
||||||
await self.bail()
|
await self.bail()
|
||||||
return
|
return
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
await self._on_connection_changed(True)
|
||||||
finally:
|
finally:
|
||||||
self._connecting_task = None
|
self._connecting_task = None
|
||||||
|
|
||||||
await self._on_connection_changed(True)
|
|
||||||
else:
|
else:
|
||||||
if self._connecting_task is not None:
|
if self._connecting_task is not None:
|
||||||
self._connecting_task.cancel()
|
self._connecting_task.cancel()
|
||||||
|
Loading…
Reference in New Issue
Block a user