mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Ensure esphome connected future is awaited when connecting is canceled (#90329)
This commit is contained in:
parent
a733ca96a2
commit
a7c796a2f7
@ -322,7 +322,17 @@ class ESPHomeClient(BaseBleakClient):
|
||||
address_type=self._address_type,
|
||||
)
|
||||
)
|
||||
except asyncio.CancelledError:
|
||||
if connected_future.done():
|
||||
with contextlib.suppress(BleakError):
|
||||
# If we are cancelled while connecting,
|
||||
# we need to make sure we await the future
|
||||
# to avoid a warning about an un-retrieved
|
||||
# exception.
|
||||
await connected_future
|
||||
raise
|
||||
except Exception:
|
||||
if connected_future.done():
|
||||
with contextlib.suppress(BleakError):
|
||||
# If the connect call throws an exception,
|
||||
# we need to make sure we await the future
|
||||
@ -330,7 +340,6 @@ class ESPHomeClient(BaseBleakClient):
|
||||
# exception since we prefer to raise the
|
||||
# exception from the connect call as it
|
||||
# will be more descriptive.
|
||||
if connected_future.done():
|
||||
await connected_future
|
||||
connected_future.cancel()
|
||||
raise
|
||||
|
Loading…
x
Reference in New Issue
Block a user