From 5f65315e86a5e06abcb80e14f80b876e8e9e5777 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 1 Mar 2024 17:43:08 -1000 Subject: [PATCH] Reduce samsungtv startup time (#112007) Create the startup tasks eagerly This one is a bit high --- homeassistant/components/samsungtv/media_player.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/samsungtv/media_player.py b/homeassistant/components/samsungtv/media_player.py index 44fce7f953f..d8f6624dfea 100644 --- a/homeassistant/components/samsungtv/media_player.py +++ b/homeassistant/components/samsungtv/media_player.py @@ -2,7 +2,7 @@ from __future__ import annotations import asyncio -from collections.abc import Coroutine, Sequence +from collections.abc import Sequence from typing import Any from async_upnp_client.aiohttp import AiohttpNotifyServer, AiohttpSessionRequester @@ -35,6 +35,7 @@ from homeassistant.helpers import config_validation as cv from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.trigger import PluggableAction +from homeassistant.util.async_ import create_eager_task from .bridge import SamsungTVBridge, SamsungTVWSBridge from .const import CONF_SSDP_RENDERING_CONTROL_LOCATION, DOMAIN, LOGGER @@ -171,15 +172,15 @@ class SamsungTVDevice(SamsungTVEntity, MediaPlayerEntity): await self._dmr_device.async_unsubscribe_services() return - startup_tasks: list[Coroutine[Any, Any, Any]] = [] + startup_tasks: list[asyncio.Task[Any]] = [] if not self._app_list_event.is_set(): - startup_tasks.append(self._async_startup_app_list()) + startup_tasks.append(create_eager_task(self._async_startup_app_list())) if self._dmr_device and not self._dmr_device.is_subscribed: - startup_tasks.append(self._async_resubscribe_dmr()) + startup_tasks.append(create_eager_task(self._async_resubscribe_dmr())) if not self._dmr_device and self._ssdp_rendering_control_location: - startup_tasks.append(self._async_startup_dmr()) + startup_tasks.append(create_eager_task(self._async_startup_dmr())) if startup_tasks: await asyncio.gather(*startup_tasks)