mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
Improve debuggability by providing job as an arg to loop.call_later (#49328)
Before `<TimerHandle when=1523538.181864923 async_track_point_in_utc_time.<locals>.run_action() at /usr/src/homeassistant/homeassistant/helpers/event.py:1177>` After `<TimerHandle when=1524977.1818648616 async_track_point_in_utc_time.<locals>.run_action(<Job HassJobType.Coroutinefunction <bound method DataUpdateCoordinator._handle_refresh_interval of <homeassistant.components.roku.RokuDataUpdateCoordinator object at 0x7fcc978a51c0>>>) at /usr/src/homeassistant/homeassistant/helpers/event.py:1175>`
This commit is contained in:
parent
0b26294fb0
commit
6048e88c8b
@ -1170,12 +1170,10 @@ def async_track_point_in_utc_time(
|
||||
|
||||
# Since this is called once, we accept a HassJob so we can avoid
|
||||
# having to figure out how to call the action every time its called.
|
||||
job = action if isinstance(action, HassJob) else HassJob(action)
|
||||
|
||||
cancel_callback: asyncio.TimerHandle | None = None
|
||||
|
||||
@callback
|
||||
def run_action() -> None:
|
||||
def run_action(job: HassJob) -> None:
|
||||
"""Call the action."""
|
||||
nonlocal cancel_callback
|
||||
|
||||
@ -1190,13 +1188,14 @@ def async_track_point_in_utc_time(
|
||||
if delta > 0:
|
||||
_LOGGER.debug("Called %f seconds too early, rearming", delta)
|
||||
|
||||
cancel_callback = hass.loop.call_later(delta, run_action)
|
||||
cancel_callback = hass.loop.call_later(delta, run_action, job)
|
||||
return
|
||||
|
||||
hass.async_run_hass_job(job, utc_point_in_time)
|
||||
|
||||
job = action if isinstance(action, HassJob) else HassJob(action)
|
||||
delta = utc_point_in_time.timestamp() - time.time()
|
||||
cancel_callback = hass.loop.call_later(delta, run_action)
|
||||
cancel_callback = hass.loop.call_later(delta, run_action, job)
|
||||
|
||||
@callback
|
||||
def unsub_point_in_time_listener() -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user