RFC - Add a 3rd state to the HA shutdown sequence for writing data#33358
RFC - Add a 3rd state to the HA shutdown sequence for writing data#33358balloob merged 7 commits intohome-assistant:devfrom
Conversation
|
So this change makes sense. One thing that we can consider (in a future PR) is that if a store is asked to write/delay write something while Home Assistant is stopping, that we hold that data until the final write event. |
how would you do that? Subscribe to stop and set a field to track that stop was called then if you get a save / delay save |
|
Add to both if hass.state == CoreState.stopping:
self._data = {…}
self._async_ensure_stop_listener()
return |
Cool. I can tackle that in another PR as suggested or in this one if ya want. |
Breaking change
shouldn't be
Proposed change
When investigating the test failures in ZHA exposed by the new exception handling I noticed there is a potential race condition in things that use the storage helper if you leverage the
EVENT_HOMEASSISTANT_STOPevent to update the data that the storage helper will write out. This PR adds an additional stage to the shutdown sequence so that the data writing can be separated from the stop event. By doing this, anything that needs or wants to update data on stop can do so and it will be written out in the subsequent stage.Type of change
Example entry for
configuration.yaml:# Example configuration.yamlAdditional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale: