mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Use eager task creation to add entities to entity platform (#111553)
This commit is contained in:
@@ -476,6 +476,7 @@ class EntityPlatform:
|
||||
task = self.hass.async_create_task(
|
||||
self.async_add_entities(new_entities, update_before_add=update_before_add),
|
||||
f"EntityPlatform async_add_entities {self.domain}.{self.platform_name}",
|
||||
eager_start=True,
|
||||
)
|
||||
|
||||
if not self._setup_complete:
|
||||
@@ -491,6 +492,7 @@ class EntityPlatform:
|
||||
self.hass,
|
||||
self.async_add_entities(new_entities, update_before_add=update_before_add),
|
||||
f"EntityPlatform async_add_entities_for_entry {self.domain}.{self.platform_name}",
|
||||
eager_start=True,
|
||||
)
|
||||
|
||||
if not self._setup_complete:
|
||||
@@ -526,9 +528,10 @@ class EntityPlatform:
|
||||
event loop and will finish faster if we run them concurrently.
|
||||
"""
|
||||
results: list[BaseException | None] | None = None
|
||||
tasks = [create_eager_task(coro) for coro in coros]
|
||||
try:
|
||||
async with self.hass.timeout.async_timeout(timeout, self.domain):
|
||||
results = await asyncio.gather(*coros, return_exceptions=True)
|
||||
results = await asyncio.gather(*tasks, return_exceptions=True)
|
||||
except TimeoutError:
|
||||
self.logger.warning(
|
||||
"Timed out adding entities for domain %s with platform %s after %ds",
|
||||
|
||||
Reference in New Issue
Block a user