Resolve auth_store loading race condition (#21794)
* Add lock in auth_store._async_load() * Python 3.5 does not like assert_called_once()
This commit is contained in:
1 parent
3ff2d99cd6
commit
3d8673dbf8
5 files changed
+80
-11
No files matched your search
@@ -38,6 +38,7 @@ class AuthStore:
|
||||
self._perm_lookup = None # type: Optional[PermissionLookup]
|
||||
self._store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY,
|
||||
private=True)
|
||||
self._lock = asyncio.Lock()
|
||||
|
||||
async def async_get_groups(self) -> List[models.Group]:
|
||||
"""Retrieve all users."""
|
||||
@@ -271,6 +272,13 @@ class AuthStore:
|
||||
self._async_schedule_save()
|
||||
|
||||
async def _async_load(self) -> None:
|
||||
"""Load the users."""
|
||||
async with self._lock:
|
||||
if self._users is not None:
|
||||
return
|
||||
await self._async_load_task()
|
||||
|
||||
async def _async_load_task(self) -> None:
|
||||
"""Load the users."""
|
||||
[ent_reg, data] = await asyncio.gather(
|
||||
self.hass.helpers.entity_registry.async_get_registry(),
|
||||
|
||||
Reference in new issue
Block a user