Run recorder shutdown tasks eagerly (#113018)

This commit is contained in:
J. Nick Koston 2024-03-26 22:25:45 -10:00 committed by GitHub
parent 1d2c2d2055
commit d8acd90370
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -476,8 +476,12 @@ class Recorder(threading.Thread):
def async_register(self) -> None:
"""Post connection initialize."""
bus = self.hass.bus
bus.async_listen_once(EVENT_HOMEASSISTANT_CLOSE, self._async_close)
bus.async_listen_once(EVENT_HOMEASSISTANT_FINAL_WRITE, self._async_shutdown)
bus.async_listen_once(
EVENT_HOMEASSISTANT_CLOSE, self._async_close, run_immediately=True
)
bus.async_listen_once(
EVENT_HOMEASSISTANT_FINAL_WRITE, self._async_shutdown, run_immediately=True
)
async_at_started(self.hass, self._async_hass_started)
@callback