1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-26 22:18:40 +00:00

Avoid writing registries to disk during startup (#112662)

This commit is contained in:
J. Nick Koston
2024-03-07 19:14:42 -10:00
committed by GitHub
parent 0382d628a3
commit caefdc6192
8 changed files with 100 additions and 42 deletions

View File

@@ -31,6 +31,7 @@ from .deprecation import (
)
from .frame import report
from .json import JSON_DUMP, find_paths_unserializable_data, json_bytes
from .registry import BaseRegistry
from .typing import UNDEFINED, UndefinedType
if TYPE_CHECKING:
@@ -45,7 +46,7 @@ EVENT_DEVICE_REGISTRY_UPDATED = "device_registry_updated"
STORAGE_KEY = "core.device_registry"
STORAGE_VERSION_MAJOR = 1
STORAGE_VERSION_MINOR = 5
SAVE_DELAY = 10
CLEANUP_DELAY = 10
CONNECTION_BLUETOOTH = "bluetooth"
@@ -456,7 +457,7 @@ class DeviceRegistryItems(UserDict[str, _EntryTypeT]):
return None
class DeviceRegistry:
class DeviceRegistry(BaseRegistry):
"""Class to hold a registry of devices."""
devices: DeviceRegistryItems[DeviceEntry]
@@ -898,11 +899,6 @@ class DeviceRegistry:
self.deleted_devices = deleted_devices
self._device_data = devices.data
@callback
def async_schedule_save(self) -> None:
"""Schedule saving the device registry."""
self._store.async_delay_save(self._data_to_save, SAVE_DELAY)
@callback
def _data_to_save(self) -> dict[str, list[dict[str, Any]]]:
"""Return data of device registry to store in a file."""