mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2025-01-25 22:12:28 +01:00
Fix failed disconnect requests not being logged (#511)
This commit is contained in:
parent
3054eb5113
commit
762d00faff
@ -799,7 +799,12 @@ class APIConnection:
|
||||
# Try to wait for the handshake to finish so we can send
|
||||
# a disconnect request. If it doesn't finish in time
|
||||
# we will just close the socket.
|
||||
await asyncio.wait([self._connect_task], timeout=5.0)
|
||||
_, pending = await asyncio.wait([self._connect_task], timeout=5.0)
|
||||
if pending:
|
||||
_LOGGER.debug(
|
||||
"%s: Connect task didn't finish before disconnect",
|
||||
self.log_name,
|
||||
)
|
||||
|
||||
self._expected_disconnect = True
|
||||
if self._is_socket_open and self._frame_helper:
|
||||
@ -811,8 +816,10 @@ class APIConnection:
|
||||
await self.send_message_await_response(
|
||||
DisconnectRequest(), DisconnectResponse
|
||||
)
|
||||
except APIConnectionError:
|
||||
pass
|
||||
except APIConnectionError as err:
|
||||
_LOGGER.error(
|
||||
"%s: Failed to send disconnect request: %s", self.log_name, err
|
||||
)
|
||||
|
||||
self._set_connection_state(ConnectionState.CLOSED)
|
||||
self._cleanup()
|
||||
|
Loading…
Reference in New Issue
Block a user