mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Save device registry store in worker thread (#157351)
This commit is contained in:
@@ -781,6 +781,7 @@ class DeviceRegistry(BaseRegistry[dict[str, list[dict[str, Any]]]]):
|
||||
STORAGE_KEY,
|
||||
atomic_writes=True,
|
||||
minor_version=STORAGE_VERSION_MINOR,
|
||||
serialize_in_event_loop=False,
|
||||
)
|
||||
|
||||
@callback
|
||||
@@ -1562,10 +1563,15 @@ class DeviceRegistry(BaseRegistry[dict[str, list[dict[str, Any]]]]):
|
||||
@callback
|
||||
def _data_to_save(self) -> dict[str, Any]:
|
||||
"""Return data of device registry to store in a file."""
|
||||
# Create intermediate lists to allow this method to be called from a thread
|
||||
# other than the event loop.
|
||||
return {
|
||||
"devices": [entry.as_storage_fragment for entry in self.devices.values()],
|
||||
"devices": [
|
||||
entry.as_storage_fragment for entry in list(self.devices.values())
|
||||
],
|
||||
"deleted_devices": [
|
||||
entry.as_storage_fragment for entry in self.deleted_devices.values()
|
||||
entry.as_storage_fragment
|
||||
for entry in list(self.deleted_devices.values())
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user