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

Add background tasks to config entries (#88335)

* Use a set for config entries task tracking

* Allow adding background tasks to config entries

* Add tests for config entry add tasks

* Update docstrings on core create task

* Migrate roon and august

* Use in more places

* Guard for None
This commit is contained in:
Paulus Schoutsen
2023-02-17 13:50:05 -05:00
committed by GitHub
parent 2b8abf84bd
commit 3a32d2bdcb
10 changed files with 82 additions and 21 deletions

View File

@@ -514,7 +514,8 @@ class HomeAssistant:
def async_create_task(self, target: Coroutine[Any, Any, _R]) -> asyncio.Task[_R]:
"""Create a task from within the eventloop.
This method must be run in the event loop.
This method must be run in the event loop. If you are using this in your
integration, use the create task methods on the config entry instead.
target: target to call.
"""
@@ -533,8 +534,7 @@ class HomeAssistant:
This is a background task which will not block startup and will be
automatically cancelled on shutdown. If you are using this in your
integration, make sure you also cancel the task when the config entry
your task belongs to is unloaded.
integration, use the create task methods on the config entry instead.
This method must be run in the event loop.
"""