From 0ae2fdc08b82ff424fbee606cd3c158e6273c66a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 23 Feb 2023 22:00:08 -0600 Subject: [PATCH] Switch samsungtv to use async_timeout to avoid task creation (#88679) wait_for creates a task, async_timeout does the same work and avoids the task creation --- homeassistant/components/samsungtv/media_player.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/samsungtv/media_player.py b/homeassistant/components/samsungtv/media_player.py index 3e544b181f1..59b4131af15 100644 --- a/homeassistant/components/samsungtv/media_player.py +++ b/homeassistant/components/samsungtv/media_player.py @@ -6,6 +6,7 @@ from collections.abc import Coroutine, Sequence from datetime import datetime, timedelta from typing import Any +import async_timeout from async_upnp_client.aiohttp import AiohttpNotifyServer, AiohttpSessionRequester from async_upnp_client.client import UpnpDevice, UpnpService, UpnpStateVariable from async_upnp_client.client_factory import UpnpFactory @@ -250,7 +251,8 @@ class SamsungTVDevice(MediaPlayerEntity): # enter it unless we have to (Python 3.11 will have zero cost try) return try: - await asyncio.wait_for(self._app_list_event.wait(), APP_LIST_DELAY) + async with async_timeout.timeout(APP_LIST_DELAY): + await self._app_list_event.wait() except asyncio.TimeoutError as err: # No need to try again self._app_list_event.set()