Raise an exception when an esp proxy gets empty services during connection so callers know to retry (#83211)
This commit is contained in:
parent
6499f5460a
commit
c617e7da31
1 changed files with 20 additions and 1 deletions
|
@ -317,7 +317,20 @@ class ESPHomeClient(BaseBleakClient):
|
|||
connected_future.cancel()
|
||||
raise
|
||||
await connected_future
|
||||
await self.get_services(dangerous_use_bleak_cache=dangerous_use_bleak_cache)
|
||||
|
||||
try:
|
||||
await self.get_services(dangerous_use_bleak_cache=dangerous_use_bleak_cache)
|
||||
except asyncio.CancelledError:
|
||||
# On cancel we must still raise cancelled error
|
||||
# to avoid blocking the cancellation even if the
|
||||
# disconnect call fails.
|
||||
with contextlib.suppress(Exception):
|
||||
await self.disconnect()
|
||||
raise
|
||||
except Exception:
|
||||
await self.disconnect()
|
||||
raise
|
||||
|
||||
self._disconnected_event = asyncio.Event()
|
||||
return True
|
||||
|
||||
|
@ -427,6 +440,12 @@ class ESPHomeClient(BaseBleakClient):
|
|||
characteristic.handle,
|
||||
)
|
||||
)
|
||||
|
||||
if not esphome_services.services:
|
||||
# If we got no services, we must have disconnected
|
||||
# or something went wrong on the ESP32's BLE stack.
|
||||
raise BleakError("Failed to get services from remote esp")
|
||||
|
||||
self.services = services
|
||||
_LOGGER.debug(
|
||||
"%s: %s - %s: Cached services saved",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue