mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Ensure storage write consume the data under the lock (#35889)
If two writes trigger at the same time the data would already be consumed.
This commit is contained in:
parent
4805723a3f
commit
6d03496372
@ -200,6 +200,12 @@ class Store:
|
|||||||
|
|
||||||
async def _async_handle_write_data(self, *_args):
|
async def _async_handle_write_data(self, *_args):
|
||||||
"""Handle writing the config."""
|
"""Handle writing the config."""
|
||||||
|
|
||||||
|
async with self._write_lock:
|
||||||
|
if self._data is None:
|
||||||
|
# Another write already consumed the data
|
||||||
|
return
|
||||||
|
|
||||||
data = self._data
|
data = self._data
|
||||||
|
|
||||||
if "data_func" in data:
|
if "data_func" in data:
|
||||||
@ -207,7 +213,6 @@ class Store:
|
|||||||
|
|
||||||
self._data = None
|
self._data = None
|
||||||
|
|
||||||
async with self._write_lock:
|
|
||||||
try:
|
try:
|
||||||
await self.hass.async_add_executor_job(
|
await self.hass.async_add_executor_job(
|
||||||
self._write_data, self.path, data
|
self._write_data, self.path, data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user