mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Ensure esphome client tasks await cancelation (#82547)
This commit is contained in:
parent
6c88574dee
commit
c91ef833f4
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import Callable, Coroutine
|
from collections.abc import Callable, Coroutine
|
||||||
|
import contextlib
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, TypeVar, cast
|
from typing import Any, TypeVar, cast
|
||||||
import uuid
|
import uuid
|
||||||
@ -65,6 +66,8 @@ def verify_connected(func: _WrapFuncType) -> _WrapFuncType:
|
|||||||
)
|
)
|
||||||
if disconnected_event.is_set():
|
if disconnected_event.is_set():
|
||||||
task.cancel()
|
task.cancel()
|
||||||
|
with contextlib.suppress(asyncio.CancelledError):
|
||||||
|
await task
|
||||||
raise BleakError(
|
raise BleakError(
|
||||||
f"{self._source}: {self._ble_device.name} - {self._ble_device.address}: " # pylint: disable=protected-access
|
f"{self._source}: {self._ble_device.name} - {self._ble_device.address}: " # pylint: disable=protected-access
|
||||||
"Disconnected during operation"
|
"Disconnected during operation"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user