mirror of
https://github.com/home-assistant/core.git
synced 2025-04-28 03:07:50 +00:00
Ensure storage task loads are always garbage collected (#42917)
This commit is contained in:
parent
3ec7258c21
commit
b47a5449e3
@ -105,6 +105,13 @@ class Store:
|
|||||||
return await self._load_task
|
return await self._load_task
|
||||||
|
|
||||||
async def _async_load(self):
|
async def _async_load(self):
|
||||||
|
"""Load the data and ensure the task is removed."""
|
||||||
|
try:
|
||||||
|
return await self._async_load_data()
|
||||||
|
finally:
|
||||||
|
self._load_task = None
|
||||||
|
|
||||||
|
async def _async_load_data(self):
|
||||||
"""Load the data."""
|
"""Load the data."""
|
||||||
# Check if we have a pending write
|
# Check if we have a pending write
|
||||||
if self._data is not None:
|
if self._data is not None:
|
||||||
@ -131,7 +138,6 @@ class Store:
|
|||||||
)
|
)
|
||||||
stored = await self._async_migrate_func(data["version"], data["data"])
|
stored = await self._async_migrate_func(data["version"], data["data"])
|
||||||
|
|
||||||
self._load_task = None
|
|
||||||
return stored
|
return stored
|
||||||
|
|
||||||
async def async_save(self, data: Union[Dict, List]) -> None:
|
async def async_save(self, data: Union[Dict, List]) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user