Simplify Recorder.async_get_commit_future (#187495)

This commit is contained in:
Erik Montnemery
2026-10-20 14:41:31 +02:00
committed by GitHub
parent e98e364767
commit 7c6727111c
+3 -4
View File
@@ -198,7 +198,7 @@ class Recorder(threading.Thread):
self.schema_version = 0
self._commits_without_expire = 0
self._event_session_has_pending_writes = False
self._processing_startup_batch = False
self._processed_startup_batch = False
self.recorder_runs_manager = RecorderRunsManager()
self.states_manager = StatesManager()
@@ -839,13 +839,12 @@ class Recorder(threading.Thread):
# has changed. This reduces the disk io.
queue_ = self._queue
startup_task_or_events: list[RecorderTask | Event] = []
self._processing_startup_batch = True
while not queue_.empty() and (task_or_event := queue_.get_nowait()):
startup_task_or_events.append(task_or_event)
self._pre_process_startup_events(startup_task_or_events)
for task in startup_task_or_events:
self._guarded_process_one_task_or_event_or_recover(task)
self._processing_startup_batch = False
self._processed_startup_batch = True
# Clear startup tasks since this thread runs forever
# and we don't want to hold them in memory
@@ -1324,7 +1323,7 @@ class Recorder(threading.Thread):
if (
self._queue.empty()
and not self._event_session_has_pending_writes
and not self._processing_startup_batch
and self._processed_startup_batch
):
return None
future: asyncio.Future[None] = self.hass.loop.create_future()