Fix async_timeout DeprecationWarnings (#97622)

This commit is contained in:
Marc Mueller 2023-08-02 20:29:03 +02:00 committed by GitHub
parent 1a77121c02
commit 0afa964724
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 12 deletions

View File

@ -1258,7 +1258,8 @@ async def async_fetch_image(
"""Retrieve an image."""
content, content_type = (None, None)
websession = async_get_clientsession(hass)
with suppress(asyncio.TimeoutError), async_timeout.timeout(10):
with suppress(asyncio.TimeoutError):
async with async_timeout.timeout(10):
response = await websession.get(url)
if response.status == HTTPStatus.OK:
content = await response.read()

View File

@ -44,7 +44,8 @@ async def _validate_input(data):
upb.connect(_connected_callback)
with suppress(asyncio.TimeoutError), async_timeout.timeout(VALIDATE_TIMEOUT):
with suppress(asyncio.TimeoutError):
async with async_timeout.timeout(VALIDATE_TIMEOUT):
await connected_event.wait()
upb.disconnect()

View File

@ -479,7 +479,8 @@ class LgWebOSMediaPlayerEntity(RestoreEntity, MediaPlayerEntity):
ssl_context = SSLContext()
websession = async_get_clientsession(self.hass)
with suppress(asyncio.TimeoutError), async_timeout.timeout(10):
with suppress(asyncio.TimeoutError):
async with async_timeout.timeout(10):
response = await websession.get(url, ssl=ssl_context)
if response.status == HTTPStatus.OK:
content = await response.read()