From d7507fd8a3d8ca1dcd37d732f148d86d908144af Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 3 Mar 2024 18:57:01 -1000 Subject: [PATCH] Run more of hassio setup in in tasks (#112151) * Run more of hassio setup in in tasks There were a few more places were we waited in sequence where we have to make remote api calls that could be moved to tasks * tweak * tweak --- homeassistant/components/hassio/__init__.py | 26 ++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/hassio/__init__.py b/homeassistant/components/hassio/__init__.py index 7a87e5026c1..8e8d077c838 100644 --- a/homeassistant/components/hassio/__init__.py +++ b/homeassistant/components/hassio/__init__.py @@ -375,6 +375,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa: hass.bus.async_listen(EVENT_CORE_CONFIG_UPDATE, push_config) push_config_task = hass.async_create_task(push_config(None), eager_start=True) + # Start listening for problems with supervisor and making issues + hass.data[DATA_KEY_SUPERVISOR_ISSUES] = issues = SupervisorIssues(hass, hassio) + issues_task = hass.async_create_task(issues.setup(), eager_start=True) async def async_service_handler(service: ServiceCall) -> None: """Handle service calls for Hass.io.""" @@ -435,8 +438,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa: ) # Fetch data - await update_info_data() - await push_config_task + update_info_task = hass.async_create_task(update_info_data(), eager_start=True) async def _async_stop(hass: HomeAssistant, restart: bool) -> None: """Stop or restart home assistant.""" @@ -459,7 +461,18 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa: async_setup_ingress_view(hass, host) # Init add-on ingress panels - await async_setup_addon_panel(hass, hassio) + panels_task = hass.async_create_task( + async_setup_addon_panel(hass, hassio), eager_start=True + ) + + # Make sure to await the update_info task before + # _async_setup_hardware_integration is called + # so the hardware integration can be set up + # and does not fallback to calling later + await panels_task + await update_info_task + await push_config_task + await issues_task # Setup hardware integration for the detected board type @callback @@ -480,7 +493,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa: hass.async_create_task( hass.config_entries.flow.async_init( hw_integration, context={"source": "system"} - ) + ), + eager_start=True, ) async_setup_hardware_integration_job = HassJob( @@ -494,10 +508,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa: eager_start=True, ) - # Start listening for problems with supervisor and making issues - hass.data[DATA_KEY_SUPERVISOR_ISSUES] = issues = SupervisorIssues(hass, hassio) - await issues.setup() - return True