mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +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,
|
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:
|
except Exception:
|
||||||
|
if connected_future.done():
|
||||||
with contextlib.suppress(BleakError):
|
with contextlib.suppress(BleakError):
|
||||||
# If the connect call throws an exception,
|
# If the connect call throws an exception,
|
||||||
# we need to make sure we await the future
|
# we need to make sure we await the future
|
||||||
@ -330,7 +340,6 @@ class ESPHomeClient(BaseBleakClient):
|
|||||||
# exception since we prefer to raise the
|
# exception since we prefer to raise the
|
||||||
# exception from the connect call as it
|
# exception from the connect call as it
|
||||||
# will be more descriptive.
|
# will be more descriptive.
|
||||||
if connected_future.done():
|
|
||||||
await connected_future
|
await connected_future
|
||||||
connected_future.cancel()
|
connected_future.cancel()
|
||||||
raise
|
raise
|
||||||
|
Loading…
x
Reference in New Issue
Block a user