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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 413 additions and 333 deletions

View file

@ -72,7 +72,7 @@ async def test_polling_only_updates_entities_it_should_poll(
poll_ent.async_update.reset_mock()
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=20))
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
assert not no_poll_ent.async_update.called
assert poll_ent.async_update.called
@ -121,7 +121,7 @@ async def test_polling_updates_entities_with_exception(hass: HomeAssistant) -> N
update_err.clear()
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=20))
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
assert len(update_ok) == 3
assert len(update_err) == 1
@ -140,7 +140,7 @@ async def test_update_state_adds_entities(hass: HomeAssistant) -> None:
ent2.update = lambda *_: component.add_entities([ent1])
async_fire_time_changed(hass, dt_util.utcnow() + DEFAULT_SCAN_INTERVAL)
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
assert len(hass.states.async_entity_ids()) == 2