mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Migrate legacy device_tracker task creation to use eager_start (#114703)
Many of these can finish synchronously without being scheduled on the loop
This commit is contained in:
parent
e870d420a6
commit
742643936f
@ -524,7 +524,7 @@ def async_setup_scanner_platform(
|
|||||||
]
|
]
|
||||||
kwargs["gps_accuracy"] = 0
|
kwargs["gps_accuracy"] = 0
|
||||||
|
|
||||||
hass.async_create_task(async_see_device(**kwargs))
|
hass.async_create_task(async_see_device(**kwargs), eager_start=True)
|
||||||
|
|
||||||
cancel_legacy_scan = async_track_time_interval(
|
cancel_legacy_scan = async_track_time_interval(
|
||||||
hass,
|
hass,
|
||||||
@ -532,7 +532,7 @@ def async_setup_scanner_platform(
|
|||||||
interval,
|
interval,
|
||||||
name=f"device_tracker {platform} legacy scan",
|
name=f"device_tracker {platform} legacy scan",
|
||||||
)
|
)
|
||||||
hass.async_create_task(async_device_tracker_scan(None))
|
hass.async_create_task(async_device_tracker_scan(None), eager_start=True)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _on_hass_stop(_: Event) -> None:
|
def _on_hass_stop(_: Event) -> None:
|
||||||
@ -722,7 +722,8 @@ class DeviceTracker:
|
|||||||
self.hass.async_create_task(
|
self.hass.async_create_task(
|
||||||
self.async_update_config(
|
self.async_update_config(
|
||||||
self.hass.config.path(YAML_DEVICES), dev_id, device
|
self.hass.config.path(YAML_DEVICES), dev_id, device
|
||||||
)
|
),
|
||||||
|
eager_start=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_update_config(self, path: str, dev_id: str, device: Device) -> None:
|
async def async_update_config(self, path: str, dev_id: str, device: Device) -> None:
|
||||||
@ -743,7 +744,9 @@ class DeviceTracker:
|
|||||||
"""
|
"""
|
||||||
for device in self.devices.values():
|
for device in self.devices.values():
|
||||||
if (device.track and device.last_update_home) and device.stale(now):
|
if (device.track and device.last_update_home) and device.stale(now):
|
||||||
self.hass.async_create_task(device.async_update_ha_state(True))
|
self.hass.async_create_task(
|
||||||
|
device.async_update_ha_state(True), eager_start=True
|
||||||
|
)
|
||||||
|
|
||||||
async def async_setup_tracked_device(self) -> None:
|
async def async_setup_tracked_device(self) -> None:
|
||||||
"""Set up all not exists tracked devices.
|
"""Set up all not exists tracked devices.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user