diff --git a/homeassistant/components/recorder/core.py b/homeassistant/components/recorder/core.py index d2510ca39653..aa79d08b1417 100644 --- a/homeassistant/components/recorder/core.py +++ b/homeassistant/components/recorder/core.py @@ -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()