mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Use async with timeout (#85281)
This commit is contained in:
parent
9e68117a33
commit
1e78314638
@ -72,7 +72,7 @@ class HueBridge:
|
|||||||
async def async_initialize_bridge(self) -> bool:
|
async def async_initialize_bridge(self) -> bool:
|
||||||
"""Initialize Connection with the Hue API."""
|
"""Initialize Connection with the Hue API."""
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
await self.api.initialize()
|
await self.api.initialize()
|
||||||
|
|
||||||
except (LinkButtonNotPressed, Unauthorized):
|
except (LinkButtonNotPressed, Unauthorized):
|
||||||
|
@ -262,7 +262,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
async def async_safe_fetch(bridge, fetch_method):
|
async def async_safe_fetch(bridge, fetch_method):
|
||||||
"""Safely fetch data."""
|
"""Safely fetch data."""
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(4):
|
async with async_timeout.timeout(4):
|
||||||
return await bridge.async_request_call(fetch_method)
|
return await bridge.async_request_call(fetch_method)
|
||||||
except aiohue.Unauthorized as err:
|
except aiohue.Unauthorized as err:
|
||||||
await bridge.handle_unauthorized_error()
|
await bridge.handle_unauthorized_error()
|
||||||
|
@ -77,7 +77,7 @@ class PrusaLinkUpdateCoordinator(DataUpdateCoordinator, Generic[T], ABC):
|
|||||||
async def _async_update_data(self) -> T:
|
async def _async_update_data(self) -> T:
|
||||||
"""Update the data."""
|
"""Update the data."""
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(5):
|
async with async_timeout.timeout(5):
|
||||||
data = await self._fetch_data()
|
data = await self._fetch_data()
|
||||||
except InvalidAuth:
|
except InvalidAuth:
|
||||||
raise UpdateFailed("Invalid authentication") from None
|
raise UpdateFailed("Invalid authentication") from None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user