mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Fix async_timeout DeprecationWarnings (#97622)
This commit is contained in:
parent
1a77121c02
commit
0afa964724
@ -1258,12 +1258,13 @@ 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):
|
||||
response = await websession.get(url)
|
||||
if response.status == HTTPStatus.OK:
|
||||
content = await response.read()
|
||||
if content_type := response.headers.get(CONTENT_TYPE):
|
||||
content_type = content_type.split(";")[0]
|
||||
with suppress(asyncio.TimeoutError):
|
||||
async with async_timeout.timeout(10):
|
||||
response = await websession.get(url)
|
||||
if response.status == HTTPStatus.OK:
|
||||
content = await response.read()
|
||||
if content_type := response.headers.get(CONTENT_TYPE):
|
||||
content_type = content_type.split(";")[0]
|
||||
|
||||
if content is None:
|
||||
url_parts = URL(url)
|
||||
|
@ -44,8 +44,9 @@ async def _validate_input(data):
|
||||
|
||||
upb.connect(_connected_callback)
|
||||
|
||||
with suppress(asyncio.TimeoutError), async_timeout.timeout(VALIDATE_TIMEOUT):
|
||||
await connected_event.wait()
|
||||
with suppress(asyncio.TimeoutError):
|
||||
async with async_timeout.timeout(VALIDATE_TIMEOUT):
|
||||
await connected_event.wait()
|
||||
|
||||
upb.disconnect()
|
||||
|
||||
|
@ -479,10 +479,11 @@ class LgWebOSMediaPlayerEntity(RestoreEntity, MediaPlayerEntity):
|
||||
ssl_context = SSLContext()
|
||||
|
||||
websession = async_get_clientsession(self.hass)
|
||||
with suppress(asyncio.TimeoutError), async_timeout.timeout(10):
|
||||
response = await websession.get(url, ssl=ssl_context)
|
||||
if response.status == HTTPStatus.OK:
|
||||
content = await response.read()
|
||||
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()
|
||||
|
||||
if content is None:
|
||||
_LOGGER.warning("Error retrieving proxied image from %s", url)
|
||||
|
Loading…
x
Reference in New Issue
Block a user