Use asyncio.timeout [s-z] (#98452)
This commit is contained in:
parent
71d985e4d6
commit
8b0fdd6fd2
38 changed files with 62 additions and 97 deletions
|
@ -5,7 +5,6 @@ import asyncio
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from songpal import (
|
from songpal import (
|
||||||
ConnectChange,
|
ConnectChange,
|
||||||
ContentChange,
|
ContentChange,
|
||||||
|
@ -68,7 +67,7 @@ async def async_setup_entry(
|
||||||
|
|
||||||
device = Device(endpoint)
|
device = Device(endpoint)
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(
|
async with asyncio.timeout(
|
||||||
10
|
10
|
||||||
): # set timeout to avoid blocking the setup process
|
): # set timeout to avoid blocking the setup process
|
||||||
await device.get_supported_methods()
|
await device.get_supported_methods()
|
||||||
|
|
|
@ -10,7 +10,6 @@ import logging
|
||||||
import time
|
import time
|
||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
import defusedxml.ElementTree as ET
|
import defusedxml.ElementTree as ET
|
||||||
from soco.core import SoCo
|
from soco.core import SoCo
|
||||||
from soco.events_base import Event as SonosEvent, SubscriptionBase
|
from soco.events_base import Event as SonosEvent, SubscriptionBase
|
||||||
|
@ -1122,7 +1121,7 @@ class SonosSpeaker:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(5):
|
async with asyncio.timeout(5):
|
||||||
while not _test_groups(groups):
|
while not _test_groups(groups):
|
||||||
await hass.data[DATA_SONOS].topology_condition.wait()
|
await hass.data[DATA_SONOS].topology_condition.wait()
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
|
|
|
@ -4,7 +4,6 @@ from http import HTTPStatus
|
||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from pysqueezebox import Server, async_discover
|
from pysqueezebox import Server, async_discover
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
@ -131,7 +130,7 @@ class SqueezeboxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
# no host specified, see if we can discover an unconfigured LMS server
|
# no host specified, see if we can discover an unconfigured LMS server
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(TIMEOUT):
|
async with asyncio.timeout(TIMEOUT):
|
||||||
await self._discover()
|
await self._discover()
|
||||||
return await self.async_step_edit()
|
return await self.async_step_edit()
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
"""Support for SRP Energy Sensor."""
|
"""Support for SRP Energy Sensor."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from requests.exceptions import ConnectionError as ConnectError, HTTPError, Timeout
|
from requests.exceptions import ConnectionError as ConnectError, HTTPError, Timeout
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
|
@ -52,7 +52,7 @@ async def async_setup_entry(
|
||||||
end_date = dt_util.now(phx_time_zone)
|
end_date = dt_util.now(phx_time_zone)
|
||||||
start_date = end_date - timedelta(days=1)
|
start_date = end_date - timedelta(days=1)
|
||||||
|
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
hourly_usage = await hass.async_add_executor_job(
|
hourly_usage = await hass.async_add_executor_job(
|
||||||
api.usage,
|
api.usage,
|
||||||
start_date,
|
start_date,
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
"""Contains the shared Coordinator for Starlink systems."""
|
"""Contains the shared Coordinator for Starlink systems."""
|
||||||
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
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from starlink_grpc import (
|
from starlink_grpc import (
|
||||||
AlertDict,
|
AlertDict,
|
||||||
ChannelContext,
|
ChannelContext,
|
||||||
|
@ -48,7 +48,7 @@ class StarlinkUpdateCoordinator(DataUpdateCoordinator[StarlinkData]):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _async_update_data(self) -> StarlinkData:
|
async def _async_update_data(self) -> StarlinkData:
|
||||||
async with async_timeout.timeout(4):
|
async with asyncio.timeout(4):
|
||||||
try:
|
try:
|
||||||
status = await self.hass.async_add_executor_job(
|
status = await self.hass.async_add_executor_job(
|
||||||
status_data, self.channel_context
|
status_data, self.channel_context
|
||||||
|
@ -59,7 +59,7 @@ class StarlinkUpdateCoordinator(DataUpdateCoordinator[StarlinkData]):
|
||||||
|
|
||||||
async def async_stow_starlink(self, stow: bool) -> None:
|
async def async_stow_starlink(self, stow: bool) -> None:
|
||||||
"""Set whether Starlink system tied to this coordinator should be stowed."""
|
"""Set whether Starlink system tied to this coordinator should be stowed."""
|
||||||
async with async_timeout.timeout(4):
|
async with asyncio.timeout(4):
|
||||||
try:
|
try:
|
||||||
await self.hass.async_add_executor_job(
|
await self.hass.async_add_executor_job(
|
||||||
set_stow_state, not stow, self.channel_context
|
set_stow_state, not stow, self.channel_context
|
||||||
|
@ -69,7 +69,7 @@ class StarlinkUpdateCoordinator(DataUpdateCoordinator[StarlinkData]):
|
||||||
|
|
||||||
async def async_reboot_starlink(self) -> None:
|
async def async_reboot_starlink(self) -> None:
|
||||||
"""Reboot the Starlink system tied to this coordinator."""
|
"""Reboot the Starlink system tied to this coordinator."""
|
||||||
async with async_timeout.timeout(4):
|
async with asyncio.timeout(4):
|
||||||
try:
|
try:
|
||||||
await self.hass.async_add_executor_job(reboot, self.channel_context)
|
await self.hass.async_add_executor_job(reboot, self.channel_context)
|
||||||
except GrpcError as exc:
|
except GrpcError as exc:
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
"""Support for Start.ca Bandwidth Monitor."""
|
"""Support for Start.ca Bandwidth Monitor."""
|
||||||
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
|
||||||
from xml.parsers.expat import ExpatError
|
from xml.parsers.expat import ExpatError
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
import xmltodict
|
import xmltodict
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ class StartcaData:
|
||||||
"""Get the Start.ca bandwidth data from the web service."""
|
"""Get the Start.ca bandwidth data from the web service."""
|
||||||
_LOGGER.debug("Updating Start.ca usage data")
|
_LOGGER.debug("Updating Start.ca usage data")
|
||||||
url = f"https://www.start.ca/support/usage/api?key={self.api_key}"
|
url = f"https://www.start.ca/support/usage/api?key={self.api_key}"
|
||||||
async with async_timeout.timeout(REQUEST_TIMEOUT):
|
async with asyncio.timeout(REQUEST_TIMEOUT):
|
||||||
req = await self.websession.get(url)
|
req = await self.websession.get(url)
|
||||||
if req.status != HTTPStatus.OK:
|
if req.status != HTTPStatus.OK:
|
||||||
_LOGGER.error("Request failed with status: %u", req.status)
|
_LOGGER.error("Request failed with status: %u", req.status)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
"""Support for Supla devices."""
|
"""Support for Supla devices."""
|
||||||
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 asyncpysupla import SuplaAPI
|
from asyncpysupla import SuplaAPI
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ async def discover_devices(hass, hass_config):
|
||||||
for server_name, server in hass.data[DOMAIN][SUPLA_SERVERS].items():
|
for server_name, server in hass.data[DOMAIN][SUPLA_SERVERS].items():
|
||||||
|
|
||||||
async def _fetch_channels():
|
async def _fetch_channels():
|
||||||
async with async_timeout.timeout(SCAN_INTERVAL.total_seconds()):
|
async with asyncio.timeout(SCAN_INTERVAL.total_seconds()):
|
||||||
channels = {
|
channels = {
|
||||||
channel["id"]: channel
|
channel["id"]: channel
|
||||||
# pylint: disable-next=cell-var-from-loop
|
# pylint: disable-next=cell-var-from-loop
|
||||||
|
|
|
@ -6,7 +6,6 @@ import contextlib
|
||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
import switchbot
|
import switchbot
|
||||||
from switchbot import SwitchbotModel
|
from switchbot import SwitchbotModel
|
||||||
|
|
||||||
|
@ -117,7 +116,7 @@ class SwitchbotDataUpdateCoordinator(ActiveBluetoothDataUpdateCoordinator[None])
|
||||||
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."""
|
||||||
with contextlib.suppress(asyncio.TimeoutError):
|
with contextlib.suppress(asyncio.TimeoutError):
|
||||||
async with async_timeout.timeout(DEVICE_STARTUP_TIMEOUT):
|
async with asyncio.timeout(DEVICE_STARTUP_TIMEOUT):
|
||||||
await self._ready_event.wait()
|
await self._ready_event.wait()
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
"""The syncthru component."""
|
"""The syncthru component."""
|
||||||
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 pysyncthru import ConnectionMode, SyncThru, SyncThruAPINotSupported
|
from pysyncthru import ConnectionMode, SyncThru, SyncThruAPINotSupported
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
@ -32,7 +32,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
async def async_update_data() -> SyncThru:
|
async def async_update_data() -> SyncThru:
|
||||||
"""Fetch data from the printer."""
|
"""Fetch data from the printer."""
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await printer.update()
|
await printer.update()
|
||||||
except SyncThruAPINotSupported as api_error:
|
except SyncThruAPINotSupported as api_error:
|
||||||
# if an exception is thrown, printer does not support syncthru
|
# if an exception is thrown, printer does not support syncthru
|
||||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import annotations
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from systembridgeconnector.exceptions import (
|
from systembridgeconnector.exceptions import (
|
||||||
AuthenticationException,
|
AuthenticationException,
|
||||||
ConnectionClosedException,
|
ConnectionClosedException,
|
||||||
|
@ -67,7 +66,7 @@ async def async_setup_entry(
|
||||||
session=async_get_clientsession(hass),
|
session=async_get_clientsession(hass),
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
if not await version.check_supported():
|
if not await version.check_supported():
|
||||||
raise ConfigEntryNotReady(
|
raise ConfigEntryNotReady(
|
||||||
"You are not running a supported version of System Bridge. Please"
|
"You are not running a supported version of System Bridge. Please"
|
||||||
|
@ -91,7 +90,7 @@ async def async_setup_entry(
|
||||||
entry=entry,
|
entry=entry,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await coordinator.async_get_data(MODULES)
|
await coordinator.async_get_data(MODULES)
|
||||||
except AuthenticationException as exception:
|
except AuthenticationException as exception:
|
||||||
_LOGGER.error("Authentication failed for %s: %s", entry.title, exception)
|
_LOGGER.error("Authentication failed for %s: %s", entry.title, exception)
|
||||||
|
@ -109,7 +108,7 @@ async def async_setup_entry(
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Wait for initial data
|
# Wait for initial data
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
while not coordinator.is_ready:
|
while not coordinator.is_ready:
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Waiting for initial data from %s (%s)",
|
"Waiting for initial data from %s (%s)",
|
||||||
|
|
|
@ -6,7 +6,6 @@ from collections.abc import Mapping
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from systembridgeconnector.exceptions import (
|
from systembridgeconnector.exceptions import (
|
||||||
AuthenticationException,
|
AuthenticationException,
|
||||||
ConnectionClosedException,
|
ConnectionClosedException,
|
||||||
|
@ -55,7 +54,7 @@ async def _validate_input(
|
||||||
data[CONF_API_KEY],
|
data[CONF_API_KEY],
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(15):
|
async with asyncio.timeout(15):
|
||||||
await websocket_client.connect(session=async_get_clientsession(hass))
|
await websocket_client.connect(session=async_get_clientsession(hass))
|
||||||
hass.async_create_task(websocket_client.listen())
|
hass.async_create_task(websocket_client.listen())
|
||||||
response = await websocket_client.get_data(GetData(modules=["system"]))
|
response = await websocket_client.get_data(GetData(modules=["system"]))
|
||||||
|
|
|
@ -7,7 +7,6 @@ from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from pydantic import BaseModel # pylint: disable=no-name-in-module
|
from pydantic import BaseModel # pylint: disable=no-name-in-module
|
||||||
from systembridgeconnector.exceptions import (
|
from systembridgeconnector.exceptions import (
|
||||||
AuthenticationException,
|
AuthenticationException,
|
||||||
|
@ -183,7 +182,7 @@ class SystemBridgeDataUpdateCoordinator(
|
||||||
async def _setup_websocket(self) -> None:
|
async def _setup_websocket(self) -> None:
|
||||||
"""Use WebSocket for updates."""
|
"""Use WebSocket for updates."""
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(20):
|
async with asyncio.timeout(20):
|
||||||
await self.websocket_client.connect(
|
await self.websocket_client.connect(
|
||||||
session=async_get_clientsession(self.hass),
|
session=async_get_clientsession(self.hass),
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,7 +8,6 @@ from http import HTTPStatus
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import async_timeout
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.device_tracker import (
|
from homeassistant.components.device_tracker import (
|
||||||
|
@ -109,7 +108,7 @@ class TadoDeviceScanner(DeviceScanner):
|
||||||
last_results = []
|
last_results = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
# Format the URL here, so we can log the template URL if
|
# Format the URL here, so we can log the template URL if
|
||||||
# anything goes wrong without exposing username and password.
|
# anything goes wrong without exposing username and password.
|
||||||
url = self.tadoapiurl.format(
|
url = self.tadoapiurl.format(
|
||||||
|
|
|
@ -3,7 +3,6 @@ import asyncio
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from tellduslive import Session, supports_local_api
|
from tellduslive import Session, supports_local_api
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
@ -91,7 +90,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
auth_url = await self.hass.async_add_executor_job(self._get_auth_url)
|
auth_url = await self.hass.async_add_executor_job(self._get_auth_url)
|
||||||
if not auth_url:
|
if not auth_url:
|
||||||
return self.async_abort(reason="unknown_authorize_url_generation")
|
return self.async_abort(reason="unknown_authorize_url_generation")
|
||||||
|
|
|
@ -7,7 +7,6 @@ import logging
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from aiohttp.hdrs import ACCEPT, AUTHORIZATION
|
from aiohttp.hdrs import ACCEPT, AUTHORIZATION
|
||||||
import async_timeout
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
|
@ -134,7 +133,7 @@ class TtnDataStorage:
|
||||||
"""Get the current state from The Things Network Data Storage."""
|
"""Get the current state from The Things Network Data Storage."""
|
||||||
try:
|
try:
|
||||||
session = async_get_clientsession(self._hass)
|
session = async_get_clientsession(self._hass)
|
||||||
async with async_timeout.timeout(DEFAULT_TIMEOUT):
|
async with asyncio.timeout(DEFAULT_TIMEOUT):
|
||||||
response = await session.get(self._url, headers=self._headers)
|
response = await session.get(self._url, headers=self._headers)
|
||||||
|
|
||||||
except (asyncio.TimeoutError, aiohttp.ClientError):
|
except (asyncio.TimeoutError, aiohttp.ClientError):
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
"""Generic Omada API coordinator."""
|
"""Generic Omada API coordinator."""
|
||||||
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from tplink_omada_client.exceptions import OmadaClientException
|
from tplink_omada_client.exceptions import OmadaClientException
|
||||||
from tplink_omada_client.omadaclient import OmadaSiteClient
|
from tplink_omada_client.omadaclient import OmadaSiteClient
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class OmadaCoordinator(DataUpdateCoordinator[dict[str, T]], Generic[T]):
|
||||||
async def _async_update_data(self) -> dict[str, T]:
|
async def _async_update_data(self) -> dict[str, T]:
|
||||||
"""Fetch data from API endpoint."""
|
"""Fetch data from API endpoint."""
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
return await self.poll_update()
|
return await self.poll_update()
|
||||||
except OmadaClientException as err:
|
except OmadaClientException as err:
|
||||||
raise UpdateFailed(f"Error communicating with API: {err}") from err
|
raise UpdateFailed(f"Error communicating with API: {err}") from err
|
||||||
|
|
|
@ -5,7 +5,6 @@ import asyncio
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from pytradfri import Gateway, RequestError
|
from pytradfri import Gateway, RequestError
|
||||||
from pytradfri.api.aiocoap_api import APIFactory
|
from pytradfri.api.aiocoap_api import APIFactory
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -141,7 +140,7 @@ async def authenticate(
|
||||||
api_factory = await APIFactory.init(host, psk_id=identity)
|
api_factory = await APIFactory.init(host, psk_id=identity)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(5):
|
async with asyncio.timeout(5):
|
||||||
key = await api_factory.generate_psk(security_code)
|
key = await api_factory.generate_psk(security_code)
|
||||||
except RequestError as err:
|
except RequestError as err:
|
||||||
raise AuthError("invalid_security_code") from err
|
raise AuthError("invalid_security_code") from err
|
||||||
|
|
|
@ -11,7 +11,6 @@ from aiohttp import CookieJar
|
||||||
import aiounifi
|
import aiounifi
|
||||||
from aiounifi.interfaces.api_handlers import ItemEvent
|
from aiounifi.interfaces.api_handlers import ItemEvent
|
||||||
from aiounifi.websocket import WebsocketState
|
from aiounifi.websocket import WebsocketState
|
||||||
import async_timeout
|
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
@ -375,7 +374,7 @@ class UniFiController:
|
||||||
async def async_reconnect(self) -> None:
|
async def async_reconnect(self) -> None:
|
||||||
"""Try to reconnect UniFi Network session."""
|
"""Try to reconnect UniFi Network session."""
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(5):
|
async with asyncio.timeout(5):
|
||||||
await self.api.login()
|
await self.api.login()
|
||||||
self.api.start_websocket()
|
self.api.start_websocket()
|
||||||
|
|
||||||
|
@ -444,7 +443,7 @@ async def get_unifi_controller(
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await controller.check_unifi_os()
|
await controller.check_unifi_os()
|
||||||
await controller.login()
|
await controller.login()
|
||||||
return controller
|
return controller
|
||||||
|
|
|
@ -4,7 +4,6 @@ from contextlib import suppress
|
||||||
import logging
|
import logging
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
import upb_lib
|
import upb_lib
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ async def _validate_input(data):
|
||||||
upb.connect(_connected_callback)
|
upb.connect(_connected_callback)
|
||||||
|
|
||||||
with suppress(asyncio.TimeoutError):
|
with suppress(asyncio.TimeoutError):
|
||||||
async with async_timeout.timeout(VALIDATE_TIMEOUT):
|
async with asyncio.timeout(VALIDATE_TIMEOUT):
|
||||||
await connected_event.wait()
|
await connected_event.wait()
|
||||||
|
|
||||||
upb.disconnect()
|
upb.disconnect()
|
||||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import annotations
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from async_upnp_client.exceptions import UpnpConnectionError
|
from async_upnp_client.exceptions import UpnpConnectionError
|
||||||
|
|
||||||
from homeassistant.components import ssdp
|
from homeassistant.components import ssdp
|
||||||
|
@ -71,7 +70,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await device_discovered_event.wait()
|
await device_discovered_event.wait()
|
||||||
except asyncio.TimeoutError as err:
|
except asyncio.TimeoutError as err:
|
||||||
raise ConfigEntryNotReady(f"Device not discovered: {usn}") from err
|
raise ConfigEntryNotReady(f"Device not discovered: {usn}") from err
|
||||||
|
|
|
@ -7,7 +7,6 @@ import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import async_timeout
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
|
@ -79,7 +78,7 @@ async def async_http_request(hass, uri):
|
||||||
"""Perform actual request."""
|
"""Perform actual request."""
|
||||||
try:
|
try:
|
||||||
session = async_get_clientsession(hass)
|
session = async_get_clientsession(hass)
|
||||||
async with async_timeout.timeout(REQUEST_TIMEOUT):
|
async with asyncio.timeout(REQUEST_TIMEOUT):
|
||||||
req = await session.get(uri)
|
req = await session.get(uri)
|
||||||
if req.status != HTTPStatus.OK:
|
if req.status != HTTPStatus.OK:
|
||||||
return {"error": req.status}
|
return {"error": req.status}
|
||||||
|
|
|
@ -4,7 +4,6 @@ from http import HTTPStatus
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import async_timeout
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.tts import CONF_LANG, PLATFORM_SCHEMA, Provider
|
from homeassistant.components.tts import CONF_LANG, PLATFORM_SCHEMA, Provider
|
||||||
|
@ -196,7 +195,7 @@ class VoiceRSSProvider(Provider):
|
||||||
form_data["hl"] = language
|
form_data["hl"] = language
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
request = await websession.post(VOICERSS_API_URL, data=form_data)
|
request = await websession.post(VOICERSS_API_URL, data=form_data)
|
||||||
|
|
||||||
if request.status != HTTPStatus.OK:
|
if request.status != HTTPStatus.OK:
|
||||||
|
|
|
@ -10,7 +10,6 @@ from pathlib import Path
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from voip_utils import (
|
from voip_utils import (
|
||||||
CallInfo,
|
CallInfo,
|
||||||
RtcpState,
|
RtcpState,
|
||||||
|
@ -259,7 +258,7 @@ class PipelineRtpDatagramProtocol(RtpDatagramProtocol):
|
||||||
self._clear_audio_queue()
|
self._clear_audio_queue()
|
||||||
|
|
||||||
# Run pipeline with a timeout
|
# Run pipeline with a timeout
|
||||||
async with async_timeout.timeout(self.pipeline_timeout):
|
async with asyncio.timeout(self.pipeline_timeout):
|
||||||
await async_pipeline_from_audio_stream(
|
await async_pipeline_from_audio_stream(
|
||||||
self.hass,
|
self.hass,
|
||||||
context=self._context,
|
context=self._context,
|
||||||
|
@ -315,7 +314,7 @@ class PipelineRtpDatagramProtocol(RtpDatagramProtocol):
|
||||||
"""
|
"""
|
||||||
# Timeout if no audio comes in for a while.
|
# Timeout if no audio comes in for a while.
|
||||||
# This means the caller hung up.
|
# This means the caller hung up.
|
||||||
async with async_timeout.timeout(self.audio_timeout):
|
async with asyncio.timeout(self.audio_timeout):
|
||||||
chunk = await self._audio_queue.get()
|
chunk = await self._audio_queue.get()
|
||||||
|
|
||||||
while chunk:
|
while chunk:
|
||||||
|
@ -326,7 +325,7 @@ class PipelineRtpDatagramProtocol(RtpDatagramProtocol):
|
||||||
# Buffer until command starts
|
# Buffer until command starts
|
||||||
return True
|
return True
|
||||||
|
|
||||||
async with async_timeout.timeout(self.audio_timeout):
|
async with asyncio.timeout(self.audio_timeout):
|
||||||
chunk = await self._audio_queue.get()
|
chunk = await self._audio_queue.get()
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
@ -343,7 +342,7 @@ class PipelineRtpDatagramProtocol(RtpDatagramProtocol):
|
||||||
|
|
||||||
# Timeout if no audio comes in for a while.
|
# Timeout if no audio comes in for a while.
|
||||||
# This means the caller hung up.
|
# This means the caller hung up.
|
||||||
async with async_timeout.timeout(self.audio_timeout):
|
async with asyncio.timeout(self.audio_timeout):
|
||||||
chunk = await self._audio_queue.get()
|
chunk = await self._audio_queue.get()
|
||||||
|
|
||||||
while chunk:
|
while chunk:
|
||||||
|
@ -353,7 +352,7 @@ class PipelineRtpDatagramProtocol(RtpDatagramProtocol):
|
||||||
|
|
||||||
yield chunk
|
yield chunk
|
||||||
|
|
||||||
async with async_timeout.timeout(self.audio_timeout):
|
async with asyncio.timeout(self.audio_timeout):
|
||||||
chunk = await self._audio_queue.get()
|
chunk = await self._audio_queue.get()
|
||||||
|
|
||||||
def _clear_audio_queue(self) -> None:
|
def _clear_audio_queue(self) -> None:
|
||||||
|
@ -395,7 +394,7 @@ class PipelineRtpDatagramProtocol(RtpDatagramProtocol):
|
||||||
tts_samples = len(audio_bytes) / (WIDTH * CHANNELS)
|
tts_samples = len(audio_bytes) / (WIDTH * CHANNELS)
|
||||||
tts_seconds = tts_samples / RATE
|
tts_seconds = tts_samples / RATE
|
||||||
|
|
||||||
async with async_timeout.timeout(tts_seconds + self.tts_extra_timeout):
|
async with asyncio.timeout(tts_seconds + self.tts_extra_timeout):
|
||||||
# Assume TTS audio is 16Khz 16-bit mono
|
# Assume TTS audio is 16Khz 16-bit mono
|
||||||
await self._async_send_audio(audio_bytes)
|
await self._async_send_audio(audio_bytes)
|
||||||
except asyncio.TimeoutError as err:
|
except asyncio.TimeoutError as err:
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
"""Support for Volvo On Call."""
|
"""Support for Volvo On Call."""
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from aiohttp.client_exceptions import ClientResponseError
|
from aiohttp.client_exceptions import ClientResponseError
|
||||||
import async_timeout
|
|
||||||
from volvooncall import Connection
|
from volvooncall import Connection
|
||||||
from volvooncall.dashboard import Instrument
|
from volvooncall.dashboard import Instrument
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ class VolvoUpdateCoordinator(DataUpdateCoordinator[None]):
|
||||||
async def _async_update_data(self) -> None:
|
async def _async_update_data(self) -> None:
|
||||||
"""Fetch data from API endpoint."""
|
"""Fetch data from API endpoint."""
|
||||||
|
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await self.volvo_data.update()
|
await self.volvo_data.update()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import ssl
|
||||||
from typing import Any, Concatenate, ParamSpec, TypeVar, cast
|
from typing import Any, Concatenate, ParamSpec, TypeVar, cast
|
||||||
|
|
||||||
from aiowebostv import WebOsClient, WebOsTvPairError
|
from aiowebostv import WebOsClient, WebOsTvPairError
|
||||||
import async_timeout
|
|
||||||
|
|
||||||
from homeassistant import util
|
from homeassistant import util
|
||||||
from homeassistant.components.media_player import (
|
from homeassistant.components.media_player import (
|
||||||
|
@ -480,7 +479,7 @@ class LgWebOSMediaPlayerEntity(RestoreEntity, MediaPlayerEntity):
|
||||||
|
|
||||||
websession = async_get_clientsession(self.hass)
|
websession = async_get_clientsession(self.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, ssl=ssl_context)
|
response = await websession.get(url, ssl=ssl_context)
|
||||||
if response.status == HTTPStatus.OK:
|
if response.status == HTTPStatus.OK:
|
||||||
content = await response.read()
|
content = await response.read()
|
||||||
|
|
|
@ -5,7 +5,6 @@ import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import async_timeout
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
|
@ -95,7 +94,7 @@ class WorxLandroidSensor(SensorEntity):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
session = async_get_clientsession(self.hass)
|
session = async_get_clientsession(self.hass)
|
||||||
async with async_timeout.timeout(self.timeout):
|
async with asyncio.timeout(self.timeout):
|
||||||
auth = aiohttp.helpers.BasicAuth("admin", self.pin)
|
auth = aiohttp.helpers.BasicAuth("admin", self.pin)
|
||||||
mower_response = await session.get(self.url, auth=auth)
|
mower_response = await session.get(self.url, auth=auth)
|
||||||
except (asyncio.TimeoutError, aiohttp.ClientError):
|
except (asyncio.TimeoutError, aiohttp.ClientError):
|
||||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from wyoming.client import AsyncTcpClient
|
from wyoming.client import AsyncTcpClient
|
||||||
from wyoming.info import Describe, Info
|
from wyoming.info import Describe, Info
|
||||||
|
|
||||||
|
@ -55,9 +54,7 @@ async def load_wyoming_info(
|
||||||
|
|
||||||
for _ in range(retries + 1):
|
for _ in range(retries + 1):
|
||||||
try:
|
try:
|
||||||
async with AsyncTcpClient(host, port) as client, async_timeout.timeout(
|
async with AsyncTcpClient(host, port) as client, asyncio.timeout(timeout):
|
||||||
timeout
|
|
||||||
):
|
|
||||||
# Describe -> Info
|
# Describe -> Info
|
||||||
await client.write_event(Describe().event())
|
await client.write_event(Describe().event())
|
||||||
while True:
|
while True:
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
"""Support for Xiaomi Miio."""
|
"""Support for Xiaomi Miio."""
|
||||||
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
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from miio import (
|
from miio import (
|
||||||
AirFresh,
|
AirFresh,
|
||||||
AirFreshA1,
|
AirFreshA1,
|
||||||
|
@ -176,7 +176,7 @@ def _async_update_data_default(hass, device):
|
||||||
|
|
||||||
async def _async_fetch_data():
|
async def _async_fetch_data():
|
||||||
"""Fetch data from the device."""
|
"""Fetch data from the device."""
|
||||||
async with async_timeout.timeout(POLLING_TIMEOUT_SEC):
|
async with asyncio.timeout(POLLING_TIMEOUT_SEC):
|
||||||
state = await hass.async_add_executor_job(device.status)
|
state = await hass.async_add_executor_job(device.status)
|
||||||
_LOGGER.debug("Got new state: %s", state)
|
_LOGGER.debug("Got new state: %s", state)
|
||||||
return state
|
return state
|
||||||
|
@ -265,7 +265,7 @@ def _async_update_data_vacuum(
|
||||||
"""Fetch data from the device using async_add_executor_job."""
|
"""Fetch data from the device using async_add_executor_job."""
|
||||||
|
|
||||||
async def execute_update() -> VacuumCoordinatorData:
|
async def execute_update() -> VacuumCoordinatorData:
|
||||||
async with async_timeout.timeout(POLLING_TIMEOUT_SEC):
|
async with asyncio.timeout(POLLING_TIMEOUT_SEC):
|
||||||
state = await hass.async_add_executor_job(update)
|
state = await hass.async_add_executor_job(update)
|
||||||
_LOGGER.debug("Got new vacuum state: %s", state)
|
_LOGGER.debug("Got new vacuum state: %s", state)
|
||||||
return state
|
return state
|
||||||
|
|
|
@ -4,7 +4,6 @@ from http import HTTPStatus
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import async_timeout
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.tts import CONF_LANG, PLATFORM_SCHEMA, Provider
|
from homeassistant.components.tts import CONF_LANG, PLATFORM_SCHEMA, Provider
|
||||||
|
@ -120,7 +119,7 @@ class YandexSpeechKitProvider(Provider):
|
||||||
actual_language = language
|
actual_language = language
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
url_param = {
|
url_param = {
|
||||||
"text": message,
|
"text": message,
|
||||||
"lang": actual_language,
|
"lang": actual_language,
|
||||||
|
|
|
@ -10,7 +10,6 @@ import logging
|
||||||
from typing import Self
|
from typing import Self
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from async_upnp_client.search import SsdpSearchListener
|
from async_upnp_client.search import SsdpSearchListener
|
||||||
from async_upnp_client.utils import CaseInsensitiveDict
|
from async_upnp_client.utils import CaseInsensitiveDict
|
||||||
|
|
||||||
|
@ -157,7 +156,7 @@ class YeelightScanner:
|
||||||
listener.async_search((host, SSDP_TARGET[1]))
|
listener.async_search((host, SSDP_TARGET[1]))
|
||||||
|
|
||||||
with contextlib.suppress(asyncio.TimeoutError):
|
with contextlib.suppress(asyncio.TimeoutError):
|
||||||
async with async_timeout.timeout(DISCOVERY_TIMEOUT):
|
async with asyncio.timeout(DISCOVERY_TIMEOUT):
|
||||||
await host_event.wait()
|
await host_event.wait()
|
||||||
|
|
||||||
self._host_discovered_events[host].remove(host_event)
|
self._host_discovered_events[host].remove(host_event)
|
||||||
|
|
|
@ -6,7 +6,6 @@ from dataclasses import dataclass
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
from yolink.const import ATTR_DEVICE_SMART_REMOTER
|
from yolink.const import ATTR_DEVICE_SMART_REMOTER
|
||||||
from yolink.device import YoLinkDevice
|
from yolink.device import YoLinkDevice
|
||||||
from yolink.exception import YoLinkAuthFailError, YoLinkClientError
|
from yolink.exception import YoLinkAuthFailError, YoLinkClientError
|
||||||
|
@ -111,7 +110,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
)
|
)
|
||||||
yolink_home = YoLinkHome()
|
yolink_home = YoLinkHome()
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await yolink_home.async_setup(
|
await yolink_home.async_setup(
|
||||||
auth_mgr, YoLinkHomeMessageListener(hass, entry)
|
auth_mgr, YoLinkHomeMessageListener(hass, entry)
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
"""YoLink DataUpdateCoordinator."""
|
"""YoLink DataUpdateCoordinator."""
|
||||||
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 yolink.device import YoLinkDevice
|
from yolink.device import YoLinkDevice
|
||||||
from yolink.exception import YoLinkAuthFailError, YoLinkClientError
|
from yolink.exception import YoLinkAuthFailError, YoLinkClientError
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class YoLinkCoordinator(DataUpdateCoordinator[dict]):
|
||||||
async def _async_update_data(self) -> dict:
|
async def _async_update_data(self) -> dict:
|
||||||
"""Fetch device state."""
|
"""Fetch device state."""
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
device_state_resp = await self.device.fetch_state()
|
device_state_resp = await self.device.fetch_state()
|
||||||
device_state = device_state_resp.data.get(ATTR_DEVICE_STATE)
|
device_state = device_state_resp.data.get(ATTR_DEVICE_STATE)
|
||||||
if self.paired_device is not None and device_state is not None:
|
if self.paired_device is not None and device_state is not None:
|
||||||
|
|
|
@ -7,7 +7,6 @@ from collections.abc import Coroutine
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from async_timeout import timeout
|
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
from zwave_js_server.client import Client as ZwaveClient
|
||||||
from zwave_js_server.const import CommandClass, RemoveNodeReason
|
from zwave_js_server.const import CommandClass, RemoveNodeReason
|
||||||
from zwave_js_server.exceptions import BaseZwaveJSServerError, InvalidServerVersion
|
from zwave_js_server.exceptions import BaseZwaveJSServerError, InvalidServerVersion
|
||||||
|
@ -146,7 +145,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
|
|
||||||
# connect and throw error if connection failed
|
# connect and throw error if connection failed
|
||||||
try:
|
try:
|
||||||
async with timeout(CONNECT_TIMEOUT):
|
async with asyncio.timeout(CONNECT_TIMEOUT):
|
||||||
await client.connect()
|
await client.connect()
|
||||||
except InvalidServerVersion as err:
|
except InvalidServerVersion as err:
|
||||||
if use_addon:
|
if use_addon:
|
||||||
|
|
|
@ -7,7 +7,6 @@ import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from async_timeout import timeout
|
|
||||||
from serial.tools import list_ports
|
from serial.tools import list_ports
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from zwave_js_server.version import VersionInfo, get_server_version
|
from zwave_js_server.version import VersionInfo, get_server_version
|
||||||
|
@ -115,7 +114,7 @@ async def validate_input(hass: HomeAssistant, user_input: dict) -> VersionInfo:
|
||||||
async def async_get_version_info(hass: HomeAssistant, ws_address: str) -> VersionInfo:
|
async def async_get_version_info(hass: HomeAssistant, ws_address: str) -> VersionInfo:
|
||||||
"""Return Z-Wave JS version info."""
|
"""Return Z-Wave JS version info."""
|
||||||
try:
|
try:
|
||||||
async with timeout(SERVER_VERSION_TIMEOUT):
|
async with asyncio.timeout(SERVER_VERSION_TIMEOUT):
|
||||||
version_info: VersionInfo = await get_server_version(
|
version_info: VersionInfo = await get_server_version(
|
||||||
ws_address, async_get_clientsession(hass)
|
ws_address, async_get_clientsession(hass)
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
"""Tests for the Sonos config flow."""
|
"""Tests for the Sonos config flow."""
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import sys
|
|
||||||
from unittest.mock import Mock, patch
|
from unittest.mock import Mock, patch
|
||||||
|
|
||||||
if sys.version_info[:2] < (3, 11):
|
|
||||||
from async_timeout import timeout as asyncio_timeout
|
|
||||||
else:
|
|
||||||
from asyncio import timeout as asyncio_timeout
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
|
@ -377,7 +371,7 @@ async def test_async_poll_manual_hosts_6(
|
||||||
caplog.clear()
|
caplog.clear()
|
||||||
# The discovery events should not fire, wait with a timeout.
|
# The discovery events should not fire, wait with a timeout.
|
||||||
with pytest.raises(asyncio.TimeoutError):
|
with pytest.raises(asyncio.TimeoutError):
|
||||||
async with asyncio_timeout(1.0):
|
async with asyncio.timeout(1.0):
|
||||||
await speaker_1_activity.event.wait()
|
await speaker_1_activity.event.wait()
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert "Activity on Living Room" not in caplog.text
|
assert "Activity on Living Room" not in caplog.text
|
||||||
|
|
|
@ -82,7 +82,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
from asyncio import TimeoutError
|
from asyncio import TimeoutError
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.upb.config_flow.async_timeout.timeout",
|
"homeassistant.components.upb.config_flow.asyncio.timeout",
|
||||||
side_effect=TimeoutError,
|
side_effect=TimeoutError,
|
||||||
):
|
):
|
||||||
result = await valid_tcp_flow(hass, sync_complete=False)
|
result = await valid_tcp_flow(hass, sync_complete=False)
|
||||||
|
|
|
@ -3,7 +3,6 @@ import asyncio
|
||||||
import time
|
import time
|
||||||
from unittest.mock import AsyncMock, Mock, patch
|
from unittest.mock import AsyncMock, Mock, patch
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components import assist_pipeline, voip
|
from homeassistant.components import assist_pipeline, voip
|
||||||
|
@ -118,7 +117,7 @@ async def test_pipeline(
|
||||||
rtp_protocol.on_chunk(bytes(_ONE_SECOND))
|
rtp_protocol.on_chunk(bytes(_ONE_SECOND))
|
||||||
|
|
||||||
# Wait for mock pipeline to exhaust the audio stream
|
# Wait for mock pipeline to exhaust the audio stream
|
||||||
async with async_timeout.timeout(1):
|
async with asyncio.timeout(1):
|
||||||
await done.wait()
|
await done.wait()
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,7 +158,7 @@ async def test_pipeline_timeout(hass: HomeAssistant, voip_device: VoIPDevice) ->
|
||||||
rtp_protocol.on_chunk(bytes(_ONE_SECOND))
|
rtp_protocol.on_chunk(bytes(_ONE_SECOND))
|
||||||
|
|
||||||
# Wait for mock pipeline to time out
|
# Wait for mock pipeline to time out
|
||||||
async with async_timeout.timeout(1):
|
async with asyncio.timeout(1):
|
||||||
await done.wait()
|
await done.wait()
|
||||||
|
|
||||||
|
|
||||||
|
@ -200,7 +199,7 @@ async def test_stt_stream_timeout(hass: HomeAssistant, voip_device: VoIPDevice)
|
||||||
rtp_protocol.on_chunk(bytes(_ONE_SECOND))
|
rtp_protocol.on_chunk(bytes(_ONE_SECOND))
|
||||||
|
|
||||||
# Wait for mock pipeline to time out
|
# Wait for mock pipeline to time out
|
||||||
async with async_timeout.timeout(1):
|
async with asyncio.timeout(1):
|
||||||
await done.wait()
|
await done.wait()
|
||||||
|
|
||||||
|
|
||||||
|
@ -319,5 +318,5 @@ async def test_tts_timeout(
|
||||||
rtp_protocol.on_chunk(bytes(_ONE_SECOND * 4))
|
rtp_protocol.on_chunk(bytes(_ONE_SECOND * 4))
|
||||||
|
|
||||||
# Wait for mock pipeline to exhaust the audio stream
|
# Wait for mock pipeline to exhaust the audio stream
|
||||||
async with async_timeout.timeout(1):
|
async with asyncio.timeout(1):
|
||||||
await done.wait()
|
await done.wait()
|
||||||
|
|
|
@ -4,7 +4,6 @@ from dataclasses import asdict
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from unittest.mock import call, patch
|
from unittest.mock import call, patch
|
||||||
|
|
||||||
import async_timeout
|
|
||||||
import pytest
|
import pytest
|
||||||
from pywemo.exceptions import ActionException, PyWeMoException
|
from pywemo.exceptions import ActionException, PyWeMoException
|
||||||
from pywemo.subscribe import EVENT_TYPE_LONG_PRESS
|
from pywemo.subscribe import EVENT_TYPE_LONG_PRESS
|
||||||
|
@ -77,7 +76,7 @@ async def test_long_press_event(
|
||||||
"testing_params",
|
"testing_params",
|
||||||
)
|
)
|
||||||
|
|
||||||
async with async_timeout.timeout(8):
|
async with asyncio.timeout(8):
|
||||||
await got_event.wait()
|
await got_event.wait()
|
||||||
|
|
||||||
assert event_data == {
|
assert event_data == {
|
||||||
|
@ -108,7 +107,7 @@ async def test_subscription_callback(
|
||||||
pywemo_registry.callbacks[device.wemo.name], device.wemo, "", ""
|
pywemo_registry.callbacks[device.wemo.name], device.wemo, "", ""
|
||||||
)
|
)
|
||||||
|
|
||||||
async with async_timeout.timeout(8):
|
async with asyncio.timeout(8):
|
||||||
await got_callback.wait()
|
await got_callback.wait()
|
||||||
assert device.last_update_success
|
assert device.last_update_success
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue