1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Schedule polling as periodic tasks (#112640)

* Schedule periodic coordinator updates as background tasks.

Currently, the coordinator's periodic refreshes delay startup because they are not scheduled as background tasks. We will wait if the startup takes long enough for the first planned refresh. Another coordinator's scheduled refresh will be fired on busy systems, further delaying the startup. This chain of events results in the startup taking a long time and hitting the safety timeout because too many coordinators are refreshing.

This case can also happen with scheduled entity refreshes, but it's less common. A future PR will address that case.

* periodic_tasks

* periodic_tasks

* periodic_tasks

* merge

* merge

* merge

* merge

* merge

* fix test that call the sync api from async

* one more place

* cannot chain

* async_run_periodic_hass_job

* sun and pattern time changes from automations also block startup

* Revert "sun and pattern time changes from automations also block startup"

This reverts commit 6de2defa05.

* make sure polling is cancelled when config entry is unloaded

* Revert "Revert "sun and pattern time changes from automations also block startup""

This reverts commit e8f12aad55.

* remove DisabledError from homewizard test as it relies on a race

* fix race

* direct coverage
This commit is contained in:
J. Nick Koston
2024-03-07 18:32:26 -10:00
committed by GitHub
parent 5da629b3e5
commit a6b17dbe68
12 changed files with 292 additions and 51 deletions

View File

@@ -877,7 +877,7 @@ async def _async_set_up_integrations(
_LOGGER.debug("Waiting for startup to wrap up")
try:
async with hass.timeout.async_timeout(WRAP_UP_TIMEOUT, cool_down=COOLDOWN_TIME):
await hass.async_block_till_done()
await hass.async_block_till_done(wait_periodic_tasks=False)
except TimeoutError:
_LOGGER.warning(
"Setup timed out for bootstrap waiting on %s - moving forward",