Add storage helper and migrate config entries (#15045)

* Add storage helper

* Migrate config entries to use the storage helper

* Make sure tests do not do I/O

* Lint

* Add versions to stored data

* Add more instance variables

* Make migrator load config if nothing to migrate

* Address comments
This commit is contained in:
Paulus Schoutsen
2018-06-25 12:53:49 -04:00
committed by GitHub
parent 672a3c7178
commit ae51dc08bf
8 changed files with 384 additions and 46 deletions

View File

@@ -230,6 +230,20 @@ class HomeAssistant(object):
return task
@callback
def async_add_executor_job(
self,
target: Callable[..., Any],
*args: Any) -> asyncio.tasks.Task:
"""Add an executor job from within the event loop."""
task = self.loop.run_in_executor(None, target, *args)
# If a task is scheduled
if self._track_task:
self._pending_tasks.append(task)
return task
@callback
def async_track_tasks(self):
"""Track tasks so you can wait for all tasks to be done."""