mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use asyncio.timeout [i-n] (#98450)
This commit is contained in:
parent
35b914af97
commit
71d985e4d6
@ -4,7 +4,6 @@ from __future__ import annotations
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from async_timeout import timeout
|
|
||||||
from pyialarm import IAlarm
|
from pyialarm import IAlarm
|
||||||
|
|
||||||
from homeassistant.components.alarm_control_panel import SCAN_INTERVAL
|
from homeassistant.components.alarm_control_panel import SCAN_INTERVAL
|
||||||
@ -27,7 +26,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
ialarm = IAlarm(host, port)
|
ialarm = IAlarm(host, port)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with timeout(10):
|
async with asyncio.timeout(10):
|
||||||
mac = await hass.async_add_executor_job(ialarm.get_mac)
|
mac = await hass.async_add_executor_job(ialarm.get_mac)
|
||||||
except (asyncio.TimeoutError, ConnectionError) as ex:
|
except (asyncio.TimeoutError, ConnectionError) as ex:
|
||||||
raise ConfigEntryNotReady from ex
|
raise ConfigEntryNotReady from ex
|
||||||
@ -81,7 +80,7 @@ class IAlarmDataUpdateCoordinator(DataUpdateCoordinator[None]):
|
|||||||
async def _async_update_data(self) -> None:
|
async def _async_update_data(self) -> None:
|
||||||
"""Fetch data from iAlarm."""
|
"""Fetch data from iAlarm."""
|
||||||
try:
|
try:
|
||||||
async with timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await self.hass.async_add_executor_job(self._update_data)
|
await self.hass.async_add_executor_job(self._update_data)
|
||||||
except ConnectionError as error:
|
except ConnectionError as error:
|
||||||
raise UpdateFailed(error) from error
|
raise UpdateFailed(error) from error
|
||||||
|
@ -5,7 +5,6 @@ import asyncio
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from iammeter import real_time_api
|
from iammeter import real_time_api
|
||||||
from iammeter.power_meter import IamMeterError
|
from iammeter.power_meter import IamMeterError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -52,7 +51,7 @@ async def async_setup_platform(
|
|||||||
config_port = config[CONF_PORT]
|
config_port = config[CONF_PORT]
|
||||||
config_name = config[CONF_NAME]
|
config_name = config[CONF_NAME]
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(PLATFORM_TIMEOUT):
|
async with asyncio.timeout(PLATFORM_TIMEOUT):
|
||||||
api = await real_time_api(config_host, config_port)
|
api = await real_time_api(config_host, config_port)
|
||||||
except (IamMeterError, asyncio.TimeoutError) as err:
|
except (IamMeterError, asyncio.TimeoutError) as err:
|
||||||
_LOGGER.error("Device is not ready")
|
_LOGGER.error("Device is not ready")
|
||||||
@ -60,7 +59,7 @@ async def async_setup_platform(
|
|||||||
|
|
||||||
async def async_update_data():
|
async def async_update_data():
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(PLATFORM_TIMEOUT):
|
async with asyncio.timeout(PLATFORM_TIMEOUT):
|
||||||
return await api.get_data()
|
return await api.get_data()
|
||||||
except (IamMeterError, asyncio.TimeoutError) as err:
|
except (IamMeterError, asyncio.TimeoutError) as err:
|
||||||
raise UpdateFailed from err
|
raise UpdateFailed from err
|
||||||
|
@ -11,7 +11,6 @@ from random import SystemRandom
|
|||||||
from typing import Final, final
|
from typing import Final, final
|
||||||
|
|
||||||
from aiohttp import hdrs, web
|
from aiohttp import hdrs, web
|
||||||
import async_timeout
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
from homeassistant.components.http import KEY_AUTHENTICATED, HomeAssistantView
|
from homeassistant.components.http import KEY_AUTHENTICATED, HomeAssistantView
|
||||||
@ -72,7 +71,7 @@ def valid_image_content_type(content_type: str | None) -> str:
|
|||||||
async def _async_get_image(image_entity: ImageEntity, timeout: int) -> Image:
|
async def _async_get_image(image_entity: ImageEntity, timeout: int) -> Image:
|
||||||
"""Fetch image from an image entity."""
|
"""Fetch image from an image entity."""
|
||||||
with suppress(asyncio.CancelledError, asyncio.TimeoutError, ImageContentTypeError):
|
with suppress(asyncio.CancelledError, asyncio.TimeoutError, ImageContentTypeError):
|
||||||
async with async_timeout.timeout(timeout):
|
async with asyncio.timeout(timeout):
|
||||||
if image_bytes := await image_entity.async_image():
|
if image_bytes := await image_entity.async_image():
|
||||||
content_type = valid_image_content_type(image_entity.content_type)
|
content_type = valid_image_content_type(image_entity.content_type)
|
||||||
image = Image(content_type, image_bytes)
|
image = Image(content_type, image_bytes)
|
||||||
|
@ -11,7 +11,6 @@ import logging
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aioimaplib import AUTH, IMAP4_SSL, NONAUTH, SELECTED, AioImapException
|
from aioimaplib import AUTH, IMAP4_SSL, NONAUTH, SELECTED, AioImapException
|
||||||
import async_timeout
|
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -408,7 +407,7 @@ class ImapPushDataUpdateCoordinator(ImapDataUpdateCoordinator):
|
|||||||
idle: asyncio.Future = await self.imap_client.idle_start()
|
idle: asyncio.Future = await self.imap_client.idle_start()
|
||||||
await self.imap_client.wait_server_push()
|
await self.imap_client.wait_server_push()
|
||||||
self.imap_client.idle_done()
|
self.imap_client.idle_done()
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await idle
|
await idle
|
||||||
|
|
||||||
# From python 3.11 asyncio.TimeoutError is an alias of TimeoutError
|
# From python 3.11 asyncio.TimeoutError is an alias of TimeoutError
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
"""The IntelliFire integration."""
|
"""The IntelliFire integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from aiohttp import ClientConnectionError
|
from aiohttp import ClientConnectionError
|
||||||
from async_timeout import timeout
|
|
||||||
from intellifire4py import IntellifirePollData
|
from intellifire4py import IntellifirePollData
|
||||||
from intellifire4py.intellifire import IntellifireAPILocal
|
from intellifire4py.intellifire import IntellifireAPILocal
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ class IntellifireDataUpdateCoordinator(DataUpdateCoordinator[IntellifirePollData
|
|||||||
await self._api.start_background_polling()
|
await self._api.start_background_polling()
|
||||||
|
|
||||||
# Don't return uninitialized poll data
|
# Don't return uninitialized poll data
|
||||||
async with timeout(15):
|
async with asyncio.timeout(15):
|
||||||
try:
|
try:
|
||||||
await self._api.poll()
|
await self._api.poll()
|
||||||
except (ConnectionError, ClientConnectionError) as exception:
|
except (ConnectionError, ClientConnectionError) as exception:
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from pyipma import IPMAException
|
from pyipma import IPMAException
|
||||||
from pyipma.api import IPMA_API
|
from pyipma.api import IPMA_API
|
||||||
from pyipma.location import Location
|
from pyipma.location import Location
|
||||||
@ -32,7 +31,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||||||
api = IPMA_API(async_get_clientsession(hass))
|
api = IPMA_API(async_get_clientsession(hass))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(30):
|
async with asyncio.timeout(30):
|
||||||
location = await Location.get(api, float(latitude), float(longitude))
|
location = await Location.get(api, float(latitude), float(longitude))
|
||||||
except (IPMAException, asyncio.TimeoutError) as err:
|
except (IPMAException, asyncio.TimeoutError) as err:
|
||||||
raise ConfigEntryNotReady(
|
raise ConfigEntryNotReady(
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
"""Support for IPMA sensors."""
|
"""Support for IPMA sensors."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from collections.abc import Callable, Coroutine
|
from collections.abc import Callable, Coroutine
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from pyipma.api import IPMA_API
|
from pyipma.api import IPMA_API
|
||||||
from pyipma.location import Location
|
from pyipma.location import Location
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ class IPMASensor(SensorEntity, IPMADevice):
|
|||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
"""Update Fire risk."""
|
"""Update Fire risk."""
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
self._attr_native_value = await self.entity_description.value_fn(
|
self._attr_native_value = await self.entity_description.value_fn(
|
||||||
self._location, self._api
|
self._location, self._api
|
||||||
)
|
)
|
||||||
|
@ -6,7 +6,6 @@ import contextlib
|
|||||||
import logging
|
import logging
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from pyipma.api import IPMA_API
|
from pyipma.api import IPMA_API
|
||||||
from pyipma.forecast import Forecast as IPMAForecast
|
from pyipma.forecast import Forecast as IPMAForecast
|
||||||
from pyipma.location import Location
|
from pyipma.location import Location
|
||||||
@ -91,7 +90,7 @@ class IPMAWeather(WeatherEntity, IPMADevice):
|
|||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
"""Update Condition and Forecast."""
|
"""Update Condition and Forecast."""
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
new_observation = await self._location.observation(self._api)
|
new_observation = await self._location.observation(self._api)
|
||||||
|
|
||||||
if new_observation:
|
if new_observation:
|
||||||
@ -225,7 +224,7 @@ class IPMAWeather(WeatherEntity, IPMADevice):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Try to update weather forecast."""
|
"""Try to update weather forecast."""
|
||||||
with contextlib.suppress(asyncio.TimeoutError):
|
with contextlib.suppress(asyncio.TimeoutError):
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await self._update_forecast(forecast_type, period, False)
|
await self._update_forecast(forecast_type, period, False)
|
||||||
|
|
||||||
async def async_forecast_daily(self) -> list[Forecast]:
|
async def async_forecast_daily(self) -> list[Forecast]:
|
||||||
|
@ -5,7 +5,6 @@ import asyncio
|
|||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from aiohttp import CookieJar
|
from aiohttp import CookieJar
|
||||||
import async_timeout
|
|
||||||
from pyisy import ISY, ISYConnectionError, ISYInvalidAuthError, ISYResponseParseError
|
from pyisy import ISY, ISYConnectionError, ISYInvalidAuthError, ISYResponseParseError
|
||||||
from pyisy.constants import CONFIG_NETWORKING, CONFIG_PORTAL
|
from pyisy.constants import CONFIG_NETWORKING, CONFIG_PORTAL
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -101,7 +100,7 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(60):
|
async with asyncio.timeout(60):
|
||||||
await isy.initialize()
|
await isy.initialize()
|
||||||
except asyncio.TimeoutError as err:
|
except asyncio.TimeoutError as err:
|
||||||
raise ConfigEntryNotReady(
|
raise ConfigEntryNotReady(
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
"""Config flow for Universal Devices ISY/IoX integration."""
|
"""Config flow for Universal Devices ISY/IoX integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from urllib.parse import urlparse, urlunparse
|
from urllib.parse import urlparse, urlunparse
|
||||||
|
|
||||||
from aiohttp import CookieJar
|
from aiohttp import CookieJar
|
||||||
import async_timeout
|
|
||||||
from pyisy import ISYConnectionError, ISYInvalidAuthError, ISYResponseParseError
|
from pyisy import ISYConnectionError, ISYInvalidAuthError, ISYResponseParseError
|
||||||
from pyisy.configuration import Configuration
|
from pyisy.configuration import Configuration
|
||||||
from pyisy.connection import Connection
|
from pyisy.connection import Connection
|
||||||
@ -97,7 +97,7 @@ async def validate_input(
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(30):
|
async with asyncio.timeout(30):
|
||||||
isy_conf_xml = await isy_conn.test_connection()
|
isy_conf_xml = await isy_conn.test_connection()
|
||||||
except ISYInvalidAuthError as error:
|
except ISYInvalidAuthError as error:
|
||||||
raise InvalidAuth from error
|
raise InvalidAuth from error
|
||||||
|
@ -4,8 +4,6 @@ import asyncio
|
|||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from async_timeout import timeout
|
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import config_entry_flow
|
from homeassistant.helpers import config_entry_flow
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
@ -28,7 +26,7 @@ async def _async_has_devices(hass: HomeAssistant) -> bool:
|
|||||||
disco = await async_start_discovery_service(hass)
|
disco = await async_start_discovery_service(hass)
|
||||||
|
|
||||||
with suppress(asyncio.TimeoutError):
|
with suppress(asyncio.TimeoutError):
|
||||||
async with timeout(TIMEOUT_DISCOVERY):
|
async with asyncio.timeout(TIMEOUT_DISCOVERY):
|
||||||
await controller_ready.wait()
|
await controller_ready.wait()
|
||||||
|
|
||||||
if not disco.pi_disco.controllers:
|
if not disco.pi_disco.controllers:
|
||||||
|
@ -3,7 +3,6 @@ import asyncio
|
|||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
|
||||||
from aiohttp.client_exceptions import ClientConnectorError, ClientResponseError
|
from aiohttp.client_exceptions import ClientConnectorError, ClientResponseError
|
||||||
import async_timeout
|
|
||||||
from kaiterra_async_client import AQIStandard, KaiterraAPIClient, Units
|
from kaiterra_async_client import AQIStandard, KaiterraAPIClient, Units
|
||||||
|
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_DEVICE_ID, CONF_DEVICES, CONF_TYPE
|
from homeassistant.const import CONF_API_KEY, CONF_DEVICE_ID, CONF_DEVICES, CONF_TYPE
|
||||||
@ -53,7 +52,7 @@ class KaiterraApiData:
|
|||||||
"""Get the data from Kaiterra API."""
|
"""Get the data from Kaiterra API."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
data = await self._api.get_latest_sensor_readings(self._devices)
|
data = await self._api.get_latest_sensor_readings(self._devices)
|
||||||
except (ClientResponseError, ClientConnectorError, asyncio.TimeoutError) as err:
|
except (ClientResponseError, ClientConnectorError, asyncio.TimeoutError) as err:
|
||||||
_LOGGER.debug("Couldn't fetch data from Kaiterra API: %s", err)
|
_LOGGER.debug("Couldn't fetch data from Kaiterra API: %s", err)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"""The kmtronic integration."""
|
"""The kmtronic integration."""
|
||||||
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import async_timeout
|
|
||||||
from pykmtronic.auth import Auth
|
from pykmtronic.auth import Auth
|
||||||
from pykmtronic.hub import KMTronicHubAPI
|
from pykmtronic.hub import KMTronicHubAPI
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
async def async_update_data():
|
async def async_update_data():
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await hub.async_update_relays()
|
await hub.async_update_relays()
|
||||||
except aiohttp.client_exceptions.ClientResponseError as err:
|
except aiohttp.client_exceptions.ClientResponseError as err:
|
||||||
raise UpdateFailed(f"Wrong credentials: {err}") from err
|
raise UpdateFailed(f"Wrong credentials: {err}") from err
|
||||||
|
@ -5,7 +5,6 @@ import asyncio
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
import krakenex
|
import krakenex
|
||||||
import pykrakenapi
|
import pykrakenapi
|
||||||
|
|
||||||
@ -73,7 +72,7 @@ class KrakenData:
|
|||||||
once.
|
once.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
return await self._hass.async_add_executor_job(self._get_kraken_data)
|
return await self._hass.async_add_executor_job(self._get_kraken_data)
|
||||||
except pykrakenapi.pykrakenapi.KrakenAPIError as error:
|
except pykrakenapi.pykrakenapi.KrakenAPIError as error:
|
||||||
if "Unknown asset pair" in str(error):
|
if "Unknown asset pair" in str(error):
|
||||||
|
@ -5,7 +5,6 @@ import asyncio
|
|||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
import serial
|
import serial
|
||||||
from serial.tools import list_ports
|
from serial.tools import list_ports
|
||||||
import ultraheat_api
|
import ultraheat_api
|
||||||
@ -105,7 +104,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
reader = ultraheat_api.UltraheatReader(port)
|
reader = ultraheat_api.UltraheatReader(port)
|
||||||
heat_meter = ultraheat_api.HeatMeterService(reader)
|
heat_meter = ultraheat_api.HeatMeterService(reader)
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(ULTRAHEAT_TIMEOUT):
|
async with asyncio.timeout(ULTRAHEAT_TIMEOUT):
|
||||||
# validate and retrieve the model and device number for a unique id
|
# validate and retrieve the model and device number for a unique id
|
||||||
data = await self.hass.async_add_executor_job(heat_meter.read)
|
data = await self.hass.async_add_executor_job(heat_meter.read)
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
"""Data update coordinator for the ultraheat api."""
|
"""Data update coordinator for the ultraheat api."""
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
import serial
|
import serial
|
||||||
from ultraheat_api.response import HeatMeterResponse
|
from ultraheat_api.response import HeatMeterResponse
|
||||||
from ultraheat_api.service import HeatMeterService
|
from ultraheat_api.service import HeatMeterService
|
||||||
@ -31,7 +31,7 @@ class UltraheatCoordinator(DataUpdateCoordinator[HeatMeterResponse]):
|
|||||||
async def _async_update_data(self) -> HeatMeterResponse:
|
async def _async_update_data(self) -> HeatMeterResponse:
|
||||||
"""Fetch data from API endpoint."""
|
"""Fetch data from API endpoint."""
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(ULTRAHEAT_TIMEOUT):
|
async with asyncio.timeout(ULTRAHEAT_TIMEOUT):
|
||||||
return await self.hass.async_add_executor_job(self.api.read)
|
return await self.hass.async_add_executor_job(self.api.read)
|
||||||
except (FileNotFoundError, serial.serialutil.SerialException) as err:
|
except (FileNotFoundError, serial.serialutil.SerialException) as err:
|
||||||
raise UpdateFailed(f"Error communicating with API: {err}") from err
|
raise UpdateFailed(f"Error communicating with API: {err}") from err
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
"""Custom DataUpdateCoordinator for the laundrify integration."""
|
"""Custom DataUpdateCoordinator for the laundrify integration."""
|
||||||
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from laundrify_aio import LaundrifyAPI
|
from laundrify_aio import LaundrifyAPI
|
||||||
from laundrify_aio.exceptions import ApiConnectionException, UnauthorizedException
|
from laundrify_aio.exceptions import ApiConnectionException, UnauthorizedException
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ class LaundrifyUpdateCoordinator(DataUpdateCoordinator[dict[str, LaundrifyDevice
|
|||||||
try:
|
try:
|
||||||
# Note: asyncio.TimeoutError and aiohttp.ClientError are already
|
# Note: asyncio.TimeoutError and aiohttp.ClientError are already
|
||||||
# handled by the data update coordinator.
|
# handled by the data update coordinator.
|
||||||
async with async_timeout.timeout(REQUEST_TIMEOUT):
|
async with asyncio.timeout(REQUEST_TIMEOUT):
|
||||||
return {m["_id"]: m for m in await self.laundrify_api.get_machines()}
|
return {m["_id"]: m for m in await self.laundrify_api.get_machines()}
|
||||||
except UnauthorizedException as err:
|
except UnauthorizedException as err:
|
||||||
# Raising ConfigEntryAuthFailed will cancel future updates
|
# Raising ConfigEntryAuthFailed will cancel future updates
|
||||||
|
@ -5,7 +5,6 @@ import asyncio
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from led_ble import BLEAK_EXCEPTIONS, LEDBLE
|
from led_ble import BLEAK_EXCEPTIONS, LEDBLE
|
||||||
|
|
||||||
from homeassistant.components import bluetooth
|
from homeassistant.components import bluetooth
|
||||||
@ -78,7 +77,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(DEVICE_TIMEOUT):
|
async with asyncio.timeout(DEVICE_TIMEOUT):
|
||||||
await startup_event.wait()
|
await startup_event.wait()
|
||||||
except asyncio.TimeoutError as ex:
|
except asyncio.TimeoutError as ex:
|
||||||
raise ConfigEntryNotReady(
|
raise ConfigEntryNotReady(
|
||||||
|
@ -8,7 +8,6 @@ from typing import Any
|
|||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from aiohttp.hdrs import AUTHORIZATION
|
from aiohttp.hdrs import AUTHORIZATION
|
||||||
import async_timeout
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.scene import Scene
|
from homeassistant.components.scene import Scene
|
||||||
@ -48,7 +47,7 @@ async def async_setup_platform(
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
httpsession = async_get_clientsession(hass)
|
httpsession = async_get_clientsession(hass)
|
||||||
async with async_timeout.timeout(timeout):
|
async with asyncio.timeout(timeout):
|
||||||
scenes_resp = await httpsession.get(url, headers=headers)
|
scenes_resp = await httpsession.get(url, headers=headers)
|
||||||
|
|
||||||
except (asyncio.TimeoutError, aiohttp.ClientError):
|
except (asyncio.TimeoutError, aiohttp.ClientError):
|
||||||
@ -90,7 +89,7 @@ class LifxCloudScene(Scene):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
httpsession = async_get_clientsession(self.hass)
|
httpsession = async_get_clientsession(self.hass)
|
||||||
async with async_timeout.timeout(self._timeout):
|
async with asyncio.timeout(self._timeout):
|
||||||
await httpsession.put(url, headers=self._headers)
|
await httpsession.put(url, headers=self._headers)
|
||||||
|
|
||||||
except (asyncio.TimeoutError, aiohttp.ClientError):
|
except (asyncio.TimeoutError, aiohttp.ClientError):
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from aiohttp.client_exceptions import ClientResponseError
|
from aiohttp.client_exceptions import ClientResponseError
|
||||||
import async_timeout
|
|
||||||
from logi_circle import LogiCircle
|
from logi_circle import LogiCircle
|
||||||
from logi_circle.exception import AuthorizationFailed
|
from logi_circle.exception import AuthorizationFailed
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -154,7 +153,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(_TIMEOUT):
|
async with asyncio.timeout(_TIMEOUT):
|
||||||
# Ensure the cameras property returns the same Camera objects for
|
# Ensure the cameras property returns the same Camera objects for
|
||||||
# all devices. Performs implicit login and session validation.
|
# all devices. Performs implicit login and session validation.
|
||||||
await logi_circle.synchronize_cameras()
|
await logi_circle.synchronize_cameras()
|
||||||
|
@ -3,7 +3,6 @@ import asyncio
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from logi_circle import LogiCircle
|
from logi_circle import LogiCircle
|
||||||
from logi_circle.exception import AuthorizationFailed
|
from logi_circle.exception import AuthorizationFailed
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -158,7 +157,7 @@ class LogiCircleFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(_TIMEOUT):
|
async with asyncio.timeout(_TIMEOUT):
|
||||||
await logi_session.authorize(code)
|
await logi_session.authorize(code)
|
||||||
except AuthorizationFailed:
|
except AuthorizationFailed:
|
||||||
(self.hass.data[DATA_FLOW_IMPL][DOMAIN][EXTERNAL_ERRORS]) = "invalid_auth"
|
(self.hass.data[DATA_FLOW_IMPL][DOMAIN][EXTERNAL_ERRORS]) = "invalid_auth"
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
"""Sensor for checking the status of London Underground tube lines."""
|
"""Sensor for checking the status of London Underground tube lines."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from london_tube_status import TubeData
|
from london_tube_status import TubeData
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ class LondonTubeCoordinator(DataUpdateCoordinator):
|
|||||||
self._data = data
|
self._data = data
|
||||||
|
|
||||||
async def _async_update_data(self):
|
async def _async_update_data(self):
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await self._data.update()
|
await self._data.update()
|
||||||
return self._data.data
|
return self._data.data
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"""Provides the coordinator for a LOQED lock."""
|
"""Provides the coordinator for a LOQED lock."""
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from typing import TypedDict
|
from typing import TypedDict
|
||||||
|
|
||||||
from aiohttp.web import Request
|
from aiohttp.web import Request
|
||||||
import async_timeout
|
|
||||||
from loqedAPI import loqed
|
from loqedAPI import loqed
|
||||||
|
|
||||||
from homeassistant.components import cloud, webhook
|
from homeassistant.components import cloud, webhook
|
||||||
@ -86,7 +86,7 @@ class LoqedDataCoordinator(DataUpdateCoordinator[StatusMessage]):
|
|||||||
|
|
||||||
async def _async_update_data(self) -> StatusMessage:
|
async def _async_update_data(self) -> StatusMessage:
|
||||||
"""Fetch data from API endpoint."""
|
"""Fetch data from API endpoint."""
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
return await self._api.async_get_lock_details()
|
return await self._api.async_get_lock_details()
|
||||||
|
|
||||||
async def _handle_webhook(
|
async def _handle_webhook(
|
||||||
|
@ -8,7 +8,6 @@ import logging
|
|||||||
import ssl
|
import ssl
|
||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from pylutron_caseta import BUTTON_STATUS_PRESSED
|
from pylutron_caseta import BUTTON_STATUS_PRESSED
|
||||||
from pylutron_caseta.smartbridge import Smartbridge
|
from pylutron_caseta.smartbridge import Smartbridge
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -173,7 +172,7 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
timed_out = True
|
timed_out = True
|
||||||
with contextlib.suppress(asyncio.TimeoutError):
|
with contextlib.suppress(asyncio.TimeoutError):
|
||||||
async with async_timeout.timeout(BRIDGE_TIMEOUT):
|
async with asyncio.timeout(BRIDGE_TIMEOUT):
|
||||||
await bridge.connect()
|
await bridge.connect()
|
||||||
timed_out = False
|
timed_out = False
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import ssl
|
import ssl
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from pylutron_caseta.pairing import PAIR_CA, PAIR_CERT, PAIR_KEY, async_pair
|
from pylutron_caseta.pairing import PAIR_CA, PAIR_CERT, PAIR_KEY, async_pair
|
||||||
from pylutron_caseta.smartbridge import Smartbridge
|
from pylutron_caseta.smartbridge import Smartbridge
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -226,7 +225,7 @@ class LutronCasetaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(BRIDGE_TIMEOUT):
|
async with asyncio.timeout(BRIDGE_TIMEOUT):
|
||||||
await bridge.connect()
|
await bridge.connect()
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""The Honeywell Lyric integration."""
|
"""The Honeywell Lyric integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import logging
|
import logging
|
||||||
@ -10,7 +11,6 @@ from aiolyric import Lyric
|
|||||||
from aiolyric.exceptions import LyricAuthenticationException, LyricException
|
from aiolyric.exceptions import LyricAuthenticationException, LyricException
|
||||||
from aiolyric.objects.device import LyricDevice
|
from aiolyric.objects.device import LyricDevice
|
||||||
from aiolyric.objects.location import LyricLocation
|
from aiolyric.objects.location import LyricLocation
|
||||||
import async_timeout
|
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
@ -74,7 +74,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
raise UpdateFailed(exception) from exception
|
raise UpdateFailed(exception) from exception
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(60):
|
async with asyncio.timeout(60):
|
||||||
await lyric.get_locations()
|
await lyric.get_locations()
|
||||||
return lyric
|
return lyric
|
||||||
except LyricAuthenticationException as exception:
|
except LyricAuthenticationException as exception:
|
||||||
|
@ -10,7 +10,6 @@ from typing import Any, Final
|
|||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from aiohttp.web_exceptions import HTTPNotFound
|
from aiohttp.web_exceptions import HTTPNotFound
|
||||||
import async_timeout
|
|
||||||
|
|
||||||
from homeassistant.components import frontend
|
from homeassistant.components import frontend
|
||||||
from homeassistant.components.http import HomeAssistantView
|
from homeassistant.components.http import HomeAssistantView
|
||||||
@ -267,7 +266,7 @@ class MailboxMediaView(MailboxView):
|
|||||||
mailbox = self.get_mailbox(platform)
|
mailbox = self.get_mailbox(platform)
|
||||||
|
|
||||||
with suppress(asyncio.CancelledError, asyncio.TimeoutError):
|
with suppress(asyncio.CancelledError, asyncio.TimeoutError):
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
try:
|
try:
|
||||||
stream = await mailbox.async_get_media(msgid)
|
stream = await mailbox.async_get_media(msgid)
|
||||||
except StreamError as err:
|
except StreamError as err:
|
||||||
|
@ -4,7 +4,6 @@ from __future__ import annotations
|
|||||||
import asyncio
|
import asyncio
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from matter_server.client import MatterClient
|
from matter_server.client import MatterClient
|
||||||
from matter_server.client.exceptions import CannotConnect, InvalidServerVersion
|
from matter_server.client.exceptions import CannotConnect, InvalidServerVersion
|
||||||
from matter_server.common.errors import MatterError, NodeCommissionFailed, NodeNotExists
|
from matter_server.common.errors import MatterError, NodeCommissionFailed, NodeNotExists
|
||||||
@ -42,7 +41,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
matter_client = MatterClient(entry.data[CONF_URL], async_get_clientsession(hass))
|
matter_client = MatterClient(entry.data[CONF_URL], async_get_clientsession(hass))
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(CONNECT_TIMEOUT):
|
async with asyncio.timeout(CONNECT_TIMEOUT):
|
||||||
await matter_client.connect()
|
await matter_client.connect()
|
||||||
except (CannotConnect, asyncio.TimeoutError) as err:
|
except (CannotConnect, asyncio.TimeoutError) as err:
|
||||||
raise ConfigEntryNotReady("Failed to connect to matter server") from err
|
raise ConfigEntryNotReady("Failed to connect to matter server") from err
|
||||||
@ -87,7 +86,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(LISTEN_READY_TIMEOUT):
|
async with asyncio.timeout(LISTEN_READY_TIMEOUT):
|
||||||
await init_ready.wait()
|
await init_ready.wait()
|
||||||
except asyncio.TimeoutError as err:
|
except asyncio.TimeoutError as err:
|
||||||
listen_task.cancel()
|
listen_task.cancel()
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
"""The Mazda Connected Services integration."""
|
"""The Mazda Connected Services integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from pymazda import (
|
from pymazda import (
|
||||||
Client as MazdaAPI,
|
Client as MazdaAPI,
|
||||||
MazdaAccountLockedException,
|
MazdaAccountLockedException,
|
||||||
@ -53,7 +53,7 @@ PLATFORMS = [
|
|||||||
|
|
||||||
async def with_timeout(task, timeout_seconds=30):
|
async def with_timeout(task, timeout_seconds=30):
|
||||||
"""Run an async task with a timeout."""
|
"""Run an async task with a timeout."""
|
||||||
async with async_timeout.timeout(timeout_seconds):
|
async with asyncio.timeout(timeout_seconds):
|
||||||
return await task
|
return await task
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
"""The Meater Temperature Probe integration."""
|
"""The Meater Temperature Probe integration."""
|
||||||
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from meater import (
|
from meater import (
|
||||||
AuthenticationError,
|
AuthenticationError,
|
||||||
MeaterApi,
|
MeaterApi,
|
||||||
@ -49,7 +49,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
try:
|
try:
|
||||||
# Note: asyncio.TimeoutError and aiohttp.ClientError are already
|
# Note: asyncio.TimeoutError and aiohttp.ClientError are already
|
||||||
# handled by the data update coordinator.
|
# handled by the data update coordinator.
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
devices: list[MeaterProbe] = await meater_api.get_all_devices()
|
devices: list[MeaterProbe] = await meater_api.get_all_devices()
|
||||||
except AuthenticationError as err:
|
except AuthenticationError as err:
|
||||||
raise ConfigEntryAuthFailed("The API call wasn't authenticated") from err
|
raise ConfigEntryAuthFailed("The API call wasn't authenticated") from err
|
||||||
|
@ -19,7 +19,6 @@ from urllib.parse import quote, urlparse
|
|||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from aiohttp.hdrs import CACHE_CONTROL, CONTENT_TYPE
|
from aiohttp.hdrs import CACHE_CONTROL, CONTENT_TYPE
|
||||||
from aiohttp.typedefs import LooseHeaders
|
from aiohttp.typedefs import LooseHeaders
|
||||||
import async_timeout
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from yarl import URL
|
from yarl import URL
|
||||||
|
|
||||||
@ -1259,7 +1258,7 @@ async def async_fetch_image(
|
|||||||
content, content_type = (None, None)
|
content, content_type = (None, None)
|
||||||
websession = async_get_clientsession(hass)
|
websession = async_get_clientsession(hass)
|
||||||
with suppress(asyncio.TimeoutError):
|
with suppress(asyncio.TimeoutError):
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
response = await websession.get(url)
|
response = await websession.get(url)
|
||||||
if response.status == HTTPStatus.OK:
|
if response.status == HTTPStatus.OK:
|
||||||
content = await response.read()
|
content = await response.read()
|
||||||
|
@ -7,7 +7,6 @@ import logging
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aiohttp import ClientConnectionError
|
from aiohttp import ClientConnectionError
|
||||||
from async_timeout import timeout
|
|
||||||
from pymelcloud import Device, get_devices
|
from pymelcloud import Device, get_devices
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -152,7 +151,7 @@ async def mel_devices_setup(
|
|||||||
"""Query connected devices from MELCloud."""
|
"""Query connected devices from MELCloud."""
|
||||||
session = async_get_clientsession(hass)
|
session = async_get_clientsession(hass)
|
||||||
try:
|
try:
|
||||||
async with timeout(10):
|
async with asyncio.timeout(10):
|
||||||
all_devices = await get_devices(
|
all_devices = await get_devices(
|
||||||
token,
|
token,
|
||||||
session,
|
session,
|
||||||
|
@ -5,7 +5,6 @@ import asyncio
|
|||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
|
||||||
from aiohttp import ClientError, ClientResponseError
|
from aiohttp import ClientError, ClientResponseError
|
||||||
from async_timeout import timeout
|
|
||||||
import pymelcloud
|
import pymelcloud
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -78,7 +77,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
):
|
):
|
||||||
"""Create client."""
|
"""Create client."""
|
||||||
try:
|
try:
|
||||||
async with timeout(10):
|
async with asyncio.timeout(10):
|
||||||
if (acquired_token := token) is None:
|
if (acquired_token := token) is None:
|
||||||
acquired_token = await pymelcloud.login(
|
acquired_token = await pymelcloud.login(
|
||||||
username,
|
username,
|
||||||
|
@ -7,7 +7,6 @@ import logging
|
|||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from aiohttp.hdrs import CONTENT_TYPE
|
from aiohttp.hdrs import CONTENT_TYPE
|
||||||
import async_timeout
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import camera
|
from homeassistant.components import camera
|
||||||
@ -314,7 +313,7 @@ class MicrosoftFace:
|
|||||||
payload = None
|
payload = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(self.timeout):
|
async with asyncio.timeout(self.timeout):
|
||||||
response = await getattr(self.websession, method)(
|
response = await getattr(self.websession, method)(
|
||||||
url, data=payload, headers=headers, params=params
|
url, data=payload, headers=headers, params=params
|
||||||
)
|
)
|
||||||
|
@ -7,7 +7,6 @@ from contextlib import suppress
|
|||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
import async_timeout
|
|
||||||
import httpx
|
import httpx
|
||||||
from yarl import URL
|
from yarl import URL
|
||||||
|
|
||||||
@ -144,7 +143,7 @@ class MjpegCamera(Camera):
|
|||||||
|
|
||||||
websession = async_get_clientsession(self.hass, verify_ssl=self._verify_ssl)
|
websession = async_get_clientsession(self.hass, verify_ssl=self._verify_ssl)
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(TIMEOUT):
|
async with asyncio.timeout(TIMEOUT):
|
||||||
response = await websession.get(self._still_image_url, auth=self._auth)
|
response = await websession.get(self._still_image_url, auth=self._auth)
|
||||||
|
|
||||||
image = await response.read()
|
image = await response.read()
|
||||||
@ -206,7 +205,7 @@ class MjpegCamera(Camera):
|
|||||||
async for chunk in stream.aiter_bytes(BUFFER_SIZE):
|
async for chunk in stream.aiter_bytes(BUFFER_SIZE):
|
||||||
if not self.hass.is_running:
|
if not self.hass.is_running:
|
||||||
break
|
break
|
||||||
async with async_timeout.timeout(TIMEOUT):
|
async with asyncio.timeout(TIMEOUT):
|
||||||
await response.write(chunk)
|
await response.write(chunk)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ from http import HTTPStatus
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import async_timeout
|
|
||||||
|
|
||||||
from homeassistant.components.notify import (
|
from homeassistant.components.notify import (
|
||||||
ATTR_DATA,
|
ATTR_DATA,
|
||||||
@ -166,7 +165,7 @@ class MobileAppNotificationService(BaseNotificationService):
|
|||||||
target_data["registration_info"] = reg_info
|
target_data["registration_info"] = reg_info
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
response = await async_get_clientsession(self._hass).post(
|
response = await async_get_clientsession(self._hass).post(
|
||||||
push_url, json=target_data
|
push_url, json=target_data
|
||||||
)
|
)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
"""The Mullvad VPN integration."""
|
"""The Mullvad VPN integration."""
|
||||||
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from mullvad_api import MullvadAPI
|
from mullvad_api import MullvadAPI
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -19,7 +19,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
"""Set up Mullvad VPN integration."""
|
"""Set up Mullvad VPN integration."""
|
||||||
|
|
||||||
async def async_get_mullvad_api_data():
|
async def async_get_mullvad_api_data():
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
api = await hass.async_add_executor_job(MullvadAPI)
|
api = await hass.async_add_executor_job(MullvadAPI)
|
||||||
return api.data
|
return api.data
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"""The mütesync integration."""
|
"""The mütesync integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
import mutesync
|
import mutesync
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -27,7 +27,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
async def update_data():
|
async def update_data():
|
||||||
"""Update the data."""
|
"""Update the data."""
|
||||||
async with async_timeout.timeout(2.5):
|
async with asyncio.timeout(2.5):
|
||||||
state = await client.get_state()
|
state = await client.get_state()
|
||||||
|
|
||||||
if state["muted"] is None or state["in_meeting"] is None:
|
if state["muted"] is None or state["in_meeting"] is None:
|
||||||
|
@ -5,7 +5,6 @@ import asyncio
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import async_timeout
|
|
||||||
import mutesync
|
import mutesync
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -27,7 +26,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str,
|
|||||||
"""
|
"""
|
||||||
session = async_get_clientsession(hass)
|
session = async_get_clientsession(hass)
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(5):
|
async with asyncio.timeout(5):
|
||||||
token = await mutesync.authenticate(session, data["host"])
|
token = await mutesync.authenticate(session, data["host"])
|
||||||
except aiohttp.ClientResponseError as error:
|
except aiohttp.ClientResponseError as error:
|
||||||
if error.status == 403:
|
if error.status == 403:
|
||||||
|
@ -9,7 +9,6 @@ import socket
|
|||||||
import sys
|
import sys
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from mysensors import BaseAsyncGateway, Message, Sensor, mysensors
|
from mysensors import BaseAsyncGateway, Message, Sensor, mysensors
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -107,7 +106,7 @@ async def try_connect(
|
|||||||
connect_task = None
|
connect_task = None
|
||||||
try:
|
try:
|
||||||
connect_task = asyncio.create_task(gateway.start())
|
connect_task = asyncio.create_task(gateway.start())
|
||||||
async with async_timeout.timeout(GATEWAY_READY_TIMEOUT):
|
async with asyncio.timeout(GATEWAY_READY_TIMEOUT):
|
||||||
await gateway_ready.wait()
|
await gateway_ready.wait()
|
||||||
return True
|
return True
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
@ -299,7 +298,7 @@ async def _gw_start(
|
|||||||
# Gatways connected via mqtt doesn't send gateway ready message.
|
# Gatways connected via mqtt doesn't send gateway ready message.
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(GATEWAY_READY_TIMEOUT):
|
async with asyncio.timeout(GATEWAY_READY_TIMEOUT):
|
||||||
await gateway_ready.wait()
|
await gateway_ready.wait()
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
|
@ -6,7 +6,6 @@ import logging
|
|||||||
from typing import cast
|
from typing import cast
|
||||||
|
|
||||||
from aiohttp.client_exceptions import ClientConnectorError, ClientError
|
from aiohttp.client_exceptions import ClientConnectorError, ClientError
|
||||||
import async_timeout
|
|
||||||
from nettigo_air_monitor import (
|
from nettigo_air_monitor import (
|
||||||
ApiError,
|
ApiError,
|
||||||
AuthFailedError,
|
AuthFailedError,
|
||||||
@ -111,7 +110,7 @@ class NAMDataUpdateCoordinator(DataUpdateCoordinator[NAMSensors]):
|
|||||||
async def _async_update_data(self) -> NAMSensors:
|
async def _async_update_data(self) -> NAMSensors:
|
||||||
"""Update data via library."""
|
"""Update data via library."""
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
data = await self.nam.async_update()
|
data = await self.nam.async_update()
|
||||||
# We do not need to catch AuthFailed exception here because sensor data is
|
# We do not need to catch AuthFailed exception here because sensor data is
|
||||||
# always available without authorization.
|
# always available without authorization.
|
||||||
|
@ -8,7 +8,6 @@ import logging
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aiohttp.client_exceptions import ClientConnectorError
|
from aiohttp.client_exceptions import ClientConnectorError
|
||||||
import async_timeout
|
|
||||||
from nettigo_air_monitor import (
|
from nettigo_air_monitor import (
|
||||||
ApiError,
|
ApiError,
|
||||||
AuthFailedError,
|
AuthFailedError,
|
||||||
@ -51,7 +50,7 @@ async def async_get_config(hass: HomeAssistant, host: str) -> NamConfig:
|
|||||||
options = ConnectionOptions(host)
|
options = ConnectionOptions(host)
|
||||||
nam = await NettigoAirMonitor.create(websession, options)
|
nam = await NettigoAirMonitor.create(websession, options)
|
||||||
|
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
mac = await nam.async_get_mac_address()
|
mac = await nam.async_get_mac_address()
|
||||||
|
|
||||||
return NamConfig(mac, nam.auth_enabled)
|
return NamConfig(mac, nam.auth_enabled)
|
||||||
@ -67,7 +66,7 @@ async def async_check_credentials(
|
|||||||
|
|
||||||
nam = await NettigoAirMonitor.create(websession, options)
|
nam = await NettigoAirMonitor.create(websession, options)
|
||||||
|
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await nam.async_check_credentials()
|
await nam.async_check_credentials()
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import logging
|
|||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
from aiohttp.client_exceptions import ClientConnectorError
|
from aiohttp.client_exceptions import ClientConnectorError
|
||||||
from async_timeout import timeout
|
|
||||||
from nextdns import (
|
from nextdns import (
|
||||||
AnalyticsDnssec,
|
AnalyticsDnssec,
|
||||||
AnalyticsEncryption,
|
AnalyticsEncryption,
|
||||||
@ -75,7 +74,7 @@ class NextDnsUpdateCoordinator(DataUpdateCoordinator[CoordinatorDataT]):
|
|||||||
async def _async_update_data(self) -> CoordinatorDataT:
|
async def _async_update_data(self) -> CoordinatorDataT:
|
||||||
"""Update data via internal method."""
|
"""Update data via internal method."""
|
||||||
try:
|
try:
|
||||||
async with timeout(10):
|
async with asyncio.timeout(10):
|
||||||
return await self._async_update_data_internal()
|
return await self._async_update_data_internal()
|
||||||
except (ApiError, ClientConnectorError, InvalidApiKeyError) as err:
|
except (ApiError, ClientConnectorError, InvalidApiKeyError) as err:
|
||||||
raise UpdateFailed(err) from err
|
raise UpdateFailed(err) from err
|
||||||
@ -162,7 +161,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
websession = async_get_clientsession(hass)
|
websession = async_get_clientsession(hass)
|
||||||
try:
|
try:
|
||||||
async with timeout(10):
|
async with asyncio.timeout(10):
|
||||||
nextdns = await NextDns.create(websession, api_key)
|
nextdns = await NextDns.create(websession, api_key)
|
||||||
except (ApiError, ClientConnectorError, asyncio.TimeoutError) as err:
|
except (ApiError, ClientConnectorError, asyncio.TimeoutError) as err:
|
||||||
raise ConfigEntryNotReady from err
|
raise ConfigEntryNotReady from err
|
||||||
|
@ -5,7 +5,6 @@ import asyncio
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aiohttp.client_exceptions import ClientConnectorError
|
from aiohttp.client_exceptions import ClientConnectorError
|
||||||
from async_timeout import timeout
|
|
||||||
from nextdns import ApiError, InvalidApiKeyError, NextDns
|
from nextdns import ApiError, InvalidApiKeyError, NextDns
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -38,7 +37,7 @@ class NextDnsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
self.api_key = user_input[CONF_API_KEY]
|
self.api_key = user_input[CONF_API_KEY]
|
||||||
try:
|
try:
|
||||||
async with timeout(10):
|
async with asyncio.timeout(10):
|
||||||
self.nextdns = await NextDns.create(
|
self.nextdns = await NextDns.create(
|
||||||
websession, user_input[CONF_API_KEY]
|
websession, user_input[CONF_API_KEY]
|
||||||
)
|
)
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
"""The Nina integration."""
|
"""The Nina integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import re
|
import re
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from async_timeout import timeout
|
|
||||||
from pynina import ApiError, Nina
|
from pynina import ApiError, Nina
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -103,7 +103,7 @@ class NINADataUpdateCoordinator(
|
|||||||
|
|
||||||
async def _async_update_data(self) -> dict[str, list[NinaWarningData]]:
|
async def _async_update_data(self) -> dict[str, list[NinaWarningData]]:
|
||||||
"""Update data."""
|
"""Update data."""
|
||||||
async with timeout(10):
|
async with asyncio.timeout(10):
|
||||||
try:
|
try:
|
||||||
await self._nina.update()
|
await self._nina.update()
|
||||||
except ApiError as err:
|
except ApiError as err:
|
||||||
|
@ -6,7 +6,6 @@ import logging
|
|||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from aiohttp.hdrs import AUTHORIZATION, USER_AGENT
|
from aiohttp.hdrs import AUTHORIZATION, USER_AGENT
|
||||||
import async_timeout
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_DOMAIN, CONF_PASSWORD, CONF_TIMEOUT, CONF_USERNAME
|
from homeassistant.const import CONF_DOMAIN, CONF_PASSWORD, CONF_TIMEOUT, CONF_USERNAME
|
||||||
@ -100,7 +99,7 @@ async def _update_no_ip(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(timeout):
|
async with asyncio.timeout(timeout):
|
||||||
resp = await session.get(url, params=params, headers=headers)
|
resp = await session.get(url, params=params, headers=headers)
|
||||||
body = await resp.text()
|
body = await resp.text()
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""The nuki component."""
|
"""The nuki component."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
@ -8,7 +9,6 @@ import logging
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
import async_timeout
|
|
||||||
from pynuki import NukiBridge, NukiLock, NukiOpener
|
from pynuki import NukiBridge, NukiLock, NukiOpener
|
||||||
from pynuki.bridge import InvalidCredentialsException
|
from pynuki.bridge import InvalidCredentialsException
|
||||||
from pynuki.device import NukiDevice
|
from pynuki.device import NukiDevice
|
||||||
@ -126,7 +126,7 @@ async def _create_webhook(
|
|||||||
ir.async_delete_issue(hass, DOMAIN, "https_webhook")
|
ir.async_delete_issue(hass, DOMAIN, "https_webhook")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await hass.async_add_executor_job(
|
await hass.async_add_executor_job(
|
||||||
_register_webhook, bridge, entry.entry_id, url
|
_register_webhook, bridge, entry.entry_id, url
|
||||||
)
|
)
|
||||||
@ -216,7 +216,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
"""Stop and remove the Nuki webhook."""
|
"""Stop and remove the Nuki webhook."""
|
||||||
webhook.async_unregister(hass, entry.entry_id)
|
webhook.async_unregister(hass, entry.entry_id)
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await hass.async_add_executor_job(
|
await hass.async_add_executor_job(
|
||||||
_remove_webhook, bridge, entry.entry_id
|
_remove_webhook, bridge, entry.entry_id
|
||||||
)
|
)
|
||||||
@ -252,7 +252,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
"""Unload the Nuki entry."""
|
"""Unload the Nuki entry."""
|
||||||
webhook.async_unregister(hass, entry.entry_id)
|
webhook.async_unregister(hass, entry.entry_id)
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await hass.async_add_executor_job(
|
await hass.async_add_executor_job(
|
||||||
_remove_webhook,
|
_remove_webhook,
|
||||||
hass.data[DOMAIN][entry.entry_id][DATA_BRIDGE],
|
hass.data[DOMAIN][entry.entry_id][DATA_BRIDGE],
|
||||||
@ -301,7 +301,7 @@ class NukiCoordinator(DataUpdateCoordinator[None]):
|
|||||||
try:
|
try:
|
||||||
# Note: asyncio.TimeoutError and aiohttp.ClientError are already
|
# Note: asyncio.TimeoutError and aiohttp.ClientError are already
|
||||||
# handled by the data update coordinator.
|
# handled by the data update coordinator.
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
events = await self.hass.async_add_executor_job(
|
events = await self.hass.async_add_executor_job(
|
||||||
self.update_devices, self.locks + self.openers
|
self.update_devices, self.locks + self.openers
|
||||||
)
|
)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
"""The nut component."""
|
"""The nut component."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import cast
|
from typing import cast
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from pynut2.nut2 import PyNUTClient, PyNUTError
|
from pynut2.nut2 import PyNUTClient, PyNUTError
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -65,7 +65,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
async def async_update_data() -> dict[str, str]:
|
async def async_update_data() -> dict[str, str]:
|
||||||
"""Fetch data from NUT."""
|
"""Fetch data from NUT."""
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await hass.async_add_executor_job(data.update)
|
await hass.async_add_executor_job(data.update)
|
||||||
if not data.status:
|
if not data.status:
|
||||||
raise UpdateFailed("Error fetching UPS state")
|
raise UpdateFailed("Error fetching UPS state")
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
"""Provides the NZBGet DataUpdateCoordinator."""
|
"""Provides the NZBGet DataUpdateCoordinator."""
|
||||||
|
import asyncio
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from async_timeout import timeout
|
|
||||||
from pynzbgetapi import NZBGetAPI, NZBGetAPIException
|
from pynzbgetapi import NZBGetAPI, NZBGetAPIException
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -96,7 +96,7 @@ class NZBGetDataUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with timeout(4):
|
async with asyncio.timeout(4):
|
||||||
return await self.hass.async_add_executor_job(_update_data)
|
return await self.hass.async_add_executor_job(_update_data)
|
||||||
except NZBGetAPIException as error:
|
except NZBGetAPIException as error:
|
||||||
raise UpdateFailed(f"Invalid response from API: {error}") from error
|
raise UpdateFailed(f"Invalid response from API: {error}") from error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user