mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 04:50:05 +00:00
Mark executor jobs as background unless created from a tracked task (#114450)
* Mark executor jobs as background unless created from a tracked task If the current task is not tracked the executor job should not be a background task to avoid delaying startup and shutdown. Currently any executor job created in a untracked task or background task would end up being tracked and delaying startup/shutdown * import exec has the same issue * Avoid tracking import executor jobs There is no reason to track these jobs as they are always awaited and we do not want to support fire and forget import executor jobs * fix xiaomi_miio * lots of fire time changed without background await * revert changes moved to other PR * more * more * more * m * m * p * fix fire and forget tests * scrape * sonos * system * more * capture callback before block * coverage * more * more races * more races * more * missed some * more fixes * missed some more * fix * remove unneeded * one more race * two
This commit is contained in:
@@ -261,7 +261,7 @@ async def test_scrape_sensor_no_data_refresh(hass: HomeAssistant) -> None:
|
||||
|
||||
mocker.payload = "test_scrape_sensor_no_data"
|
||||
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)
|
||||
|
||||
state = hass.states.get("sensor.ha_version")
|
||||
assert state is not None
|
||||
@@ -541,7 +541,7 @@ async def test_templates_with_yaml(hass: HomeAssistant) -> None:
|
||||
hass,
|
||||
dt_util.utcnow() + timedelta(minutes=10),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
state = hass.states.get("sensor.get_values_with_template")
|
||||
assert state.state == "Current Version: 2021.12.10"
|
||||
@@ -555,7 +555,7 @@ async def test_templates_with_yaml(hass: HomeAssistant) -> None:
|
||||
hass,
|
||||
dt_util.utcnow() + timedelta(minutes=20),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
state = hass.states.get("sensor.get_values_with_template")
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
@@ -568,7 +568,7 @@ async def test_templates_with_yaml(hass: HomeAssistant) -> None:
|
||||
hass,
|
||||
dt_util.utcnow() + timedelta(minutes=30),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
state = hass.states.get("sensor.get_values_with_template")
|
||||
assert state.state == "Current Version: 2021.12.10"
|
||||
@@ -608,7 +608,7 @@ async def test_availability(
|
||||
hass.states.async_set("sensor.input1", "on")
|
||||
freezer.tick(timedelta(minutes=10))
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
state = hass.states.get("sensor.current_version")
|
||||
assert state.state == "2021.12.10"
|
||||
@@ -618,7 +618,7 @@ async def test_availability(
|
||||
|
||||
freezer.tick(timedelta(minutes=10))
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
state = hass.states.get("sensor.current_version")
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
Reference in New Issue
Block a user