mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Add names to common helper tasks (#90803)
This commit is contained in:
parent
21a873f0af
commit
5eb0c35a97
@ -505,12 +505,14 @@ class HomeAssistant:
|
||||
|
||||
return task
|
||||
|
||||
def create_task(self, target: Coroutine[Any, Any, Any]) -> None:
|
||||
def create_task(
|
||||
self, target: Coroutine[Any, Any, Any], name: str | None = None
|
||||
) -> None:
|
||||
"""Add task to the executor pool.
|
||||
|
||||
target: target to call.
|
||||
"""
|
||||
self.loop.call_soon_threadsafe(self.async_create_task, target)
|
||||
self.loop.call_soon_threadsafe(self.async_create_task, target, name)
|
||||
|
||||
@callback
|
||||
def async_create_task(
|
||||
|
@ -67,7 +67,10 @@ def discover(
|
||||
hass_config: ConfigType,
|
||||
) -> None:
|
||||
"""Fire discovery event. Can ensure a component is loaded."""
|
||||
hass.add_job(async_discover(hass, service, discovered, component, hass_config))
|
||||
hass.create_task(
|
||||
async_discover(hass, service, discovered, component, hass_config),
|
||||
f"discover {service} {component} {discovered}",
|
||||
)
|
||||
|
||||
|
||||
@bind_hass
|
||||
@ -127,8 +130,9 @@ def load_platform(
|
||||
hass_config: ConfigType,
|
||||
) -> None:
|
||||
"""Load a component and platform dynamically."""
|
||||
hass.add_job(
|
||||
async_load_platform(hass, component, platform, discovered, hass_config)
|
||||
hass.create_task(
|
||||
async_load_platform(hass, component, platform, discovered, hass_config),
|
||||
f"discovery load_platform {component} {platform}",
|
||||
)
|
||||
|
||||
|
||||
|
@ -698,7 +698,10 @@ class Entity(ABC):
|
||||
If state is changed more than once before the ha state change task has
|
||||
been executed, the intermediate state transitions will be missed.
|
||||
"""
|
||||
self.hass.add_job(self.async_update_ha_state(force_refresh))
|
||||
self.hass.create_task(
|
||||
self.async_update_ha_state(force_refresh),
|
||||
f"Entity {self.entity_id} schedule update ha state",
|
||||
)
|
||||
|
||||
@callback
|
||||
def async_schedule_update_ha_state(self, force_refresh: bool = False) -> None:
|
||||
|
@ -114,7 +114,9 @@ class EntityComponent(Generic[_EntityT]):
|
||||
|
||||
This doesn't block the executor to protect from deadlocks.
|
||||
"""
|
||||
self.hass.add_job(self.async_setup(config))
|
||||
self.hass.create_task(
|
||||
self.async_setup(config), f"EntityComponent setup {self.domain}"
|
||||
)
|
||||
|
||||
async def async_setup(self, config: ConfigType) -> None:
|
||||
"""Set up a full entity component.
|
||||
|
Loading…
x
Reference in New Issue
Block a user