Replace periodic tasks with background tasks (#112726)

* Phase out periodic tasks

* false by default or some tests will block forever, will need to fix each one manually

* kwarg works

* kwarg works

* kwarg works

* fixes

* fix more tests

* fix more tests

* fix lifx

* opensky

* pvpc_hourly_pricing

* adjust more

* adjust more

* smarttub

* adjust more

* adjust more

* adjust more

* adjust more

* adjust

* no eager executor

* zha

* qnap_qsw

* fix more

* fix fix

* docs

* its a wrapper now

* add more coverage

* coverage

* cover all combos

* more fixes

* more fixes

* more fixes

* remaining issues are legit bugs in tests

* make tplink test more predictable

* more fixes

* feedreader

* grind out some more

* make test race safe

* one more
This commit is contained in:
J. Nick Koston
2024-03-08 16:45:10 -10:00
committed by GitHub
parent 08416974c9
commit 65358c129a
48 changed files with 413 additions and 333 deletions

View File

@@ -1599,7 +1599,7 @@ class _TrackTimeInterval:
self._track_job,
hass.loop.time() + self.seconds,
)
hass.async_run_periodic_hass_job(self._run_job, now)
hass.async_run_hass_job(self._run_job, now, eager_start=True, background=True)
@callback
def async_cancel(self) -> None:
@@ -1684,7 +1684,7 @@ class SunListener:
"""Handle solar event."""
self._unsub_sun = None
self._listen_next_sun_event()
self.hass.async_run_periodic_hass_job(self.job)
self.hass.async_run_hass_job(self.job, eager_start=True, background=True)
@callback
def _handle_config_event(self, _event: Any) -> None:
@@ -1770,7 +1770,9 @@ class _TrackUTCTimeChange:
# time when the timer was scheduled
utc_now = time_tracker_utcnow()
localized_now = dt_util.as_local(utc_now) if self.local else utc_now
hass.async_run_periodic_hass_job(self.job, localized_now)
hass.async_run_hass_job(
self.job, localized_now, eager_start=True, background=True
)
if TYPE_CHECKING:
assert self._pattern_time_change_listener_job is not None
self._cancel_callback = async_track_point_in_utc_time(