Ensure storage task loads are always garbage collected (#42917)

pull/42944/head
J. Nick Koston 2020-11-07 06:54:56 -10:00 committed by GitHub
parent 3ec7258c21
commit b47a5449e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -105,6 +105,13 @@ class Store:
return await self._load_task
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."""
# Check if we have a pending write
if self._data is not None:
@ -131,7 +138,6 @@ class Store:
)
stored = await self._async_migrate_func(data["version"], data["data"])
self._load_task = None
return stored
async def async_save(self, data: Union[Dict, List]) -> None: