mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Use async_timeout instead of asyncio.wait_for in switchbot (#76630)
This commit is contained in:
parent
14e6c84104
commit
4a5a039984
@ -2,9 +2,11 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import contextlib
|
||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
|
import async_timeout
|
||||||
import switchbot
|
import switchbot
|
||||||
|
|
||||||
from homeassistant.components import bluetooth
|
from homeassistant.components import bluetooth
|
||||||
@ -71,8 +73,8 @@ class SwitchbotDataUpdateCoordinator(PassiveBluetoothDataUpdateCoordinator):
|
|||||||
|
|
||||||
async def async_wait_ready(self) -> bool:
|
async def async_wait_ready(self) -> bool:
|
||||||
"""Wait for the device to be ready."""
|
"""Wait for the device to be ready."""
|
||||||
try:
|
with contextlib.suppress(asyncio.TimeoutError):
|
||||||
await asyncio.wait_for(self._ready_event.wait(), timeout=55)
|
async with async_timeout.timeout(55):
|
||||||
except asyncio.TimeoutError:
|
await self._ready_event.wait()
|
||||||
return False
|
return True
|
||||||
return True
|
return False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user