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

Add support for eager tasks (#111425)

* Add support for eager tasks

python 3.12 supports eager tasks

reading:
https://docs.python.org/3/library/asyncio-task.html#eager-task-factory
https://github.com/python/cpython/issues/97696

There are lots of places were we are unlikely to suspend, but we might
suspend so creating a task makes sense

* reduce

* revert entity

* revert

* coverage

* coverage

* coverage

* coverage

* fix test
This commit is contained in:
J. Nick Koston
2024-02-26 06:36:46 -10:00
committed by GitHub
parent 93cc6e0f36
commit 67e356904b
8 changed files with 162 additions and 18 deletions

View File

@@ -4228,11 +4228,16 @@ async def test_task_tracking(hass: HomeAssistant) -> None:
entry.async_on_unload(test_unload)
entry.async_create_task(hass, test_task())
entry.async_create_background_task(hass, test_task(), "background-task-name")
entry.async_create_background_task(
hass, test_task(), "background-task-name", eager_start=True
)
entry.async_create_background_task(
hass, test_task(), "background-task-name", eager_start=False
)
await asyncio.sleep(0)
hass.loop.call_soon(event.set)
await entry._async_process_on_unload(hass)
assert results == ["on_unload", "background", "normal"]
assert results == ["on_unload", "background", "background", "normal"]
async def test_preview_supported(