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 creationpull/88681/head^2
parent
d90ee85118
commit
0ae2fdc08b
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue