Ensure esphome client tasks await cancelation (#82547)
This commit is contained in:
parent
eaf6d43508
commit
188cdd1bac
1 changed files with 3 additions and 0 deletions
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
|
||||
import asyncio
|
||||
from collections.abc import Callable, Coroutine
|
||||
import contextlib
|
||||
import logging
|
||||
from typing import Any, TypeVar, cast
|
||||
import uuid
|
||||
|
@ -66,6 +67,8 @@ def verify_connected(func: _WrapFuncType) -> _WrapFuncType:
|
|||
)
|
||||
if disconnected_event.is_set():
|
||||
task.cancel()
|
||||
with contextlib.suppress(asyncio.CancelledError):
|
||||
await task
|
||||
raise BleakError(
|
||||
f"{self._source}: {self._ble_device.name} - {self._ble_device.address}: " # pylint: disable=protected-access
|
||||
"Disconnected during operation"
|
||||
|
|
Loading…
Add table
Reference in a new issue