Move legacy stt setup to use tracked tasks (#113718)

* Move legacy stt setup to use tracked tasks

* comment
This commit is contained in:
J. Nick Koston 2024-03-18 02:10:12 -10:00 committed by GitHub
parent 10f2d8b4b1
commit 719d373bd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,7 +3,6 @@
from __future__ import annotations
from abc import abstractmethod
import asyncio
from collections.abc import AsyncIterable
from dataclasses import asdict
import logging
@ -127,8 +126,14 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
component.register_shutdown()
platform_setups = async_setup_legacy(hass, config)
if platform_setups:
await asyncio.wait([asyncio.create_task(setup) for setup in platform_setups])
for setup in platform_setups:
# Tasks are created as tracked tasks to ensure startup
# waits for them to finish, but we explicitly do not
# want to wait for them to finish here because we want
# any config entries that use stt as a base platform
# to be able to start with out having to wait for the
# legacy platforms to finish setting up.
hass.async_create_task(setup, eager_start=True)
hass.http.register_view(SpeechToTextView(hass.data[DATA_PROVIDERS]))
return True