Ensure config entries are not unloaded while their platforms are setting up (#118767)
* Report non-awaited/non-locked config entry platform forwards Its currently possible for config entries to be reloaded while their platforms are being forwarded if platform forwards are not awaited or done after the config entry is setup since the lock will not be held in this case. In https://developers.home-assistant.io/blog/2022/07/08/config_entry_forwards we advised to await platform forwards to ensure this does not happen, however for sleeping devices and late discovered devices, platform forwards may happen later. If config platform forwards are happening during setup, they should be awaited If config entry platform forwards are not happening during setup, instead async_late_forward_entry_setups should be used which will hold the lock to prevent the config entry from being unloaded while its platforms are being setup * Report non-awaited/non-locked config entry platform forwards Its currently possible for config entries to be reloaded while their platforms are being forwarded if platform forwards are not awaited or done after the config entry is setup since the lock will not be held in this case. In https://developers.home-assistant.io/blog/2022/07/08/config_entry_forwards we advised to await platform forwards to ensure this does not happen, however for sleeping devices and late discovered devices, platform forwards may happen later. If config platform forwards are happening during setup, they should be awaited If config entry platform forwards are not happening during setup, instead async_late_forward_entry_setups should be used which will hold the lock to prevent the config entry from being unloaded while its platforms are being setup * run with error on to find them * cert_exp, hold lock * cert_exp, hold lock * shelly async_late_forward_entry_setups * compact * compact * found another * patch up mobileapp * patch up hue tests * patch up smartthings * fix mqtt * fix esphome * zwave_js * mqtt * rework * fixes * fix mocking * fix mocking * do not call async_forward_entry_setup directly * docstrings * docstrings * docstrings * add comments * doc strings * fixed all in core, turn off strict * coverage * coverage * missing * coverage
This commit is contained in:
parent
67b3be8432
commit
ed0568c655
47 changed files with 457 additions and 111 deletions
|
@ -85,9 +85,8 @@ async def test_update_entity(
|
|||
"homeassistant.components.esphome.update.DomainData.get_entry_data",
|
||||
return_value=Mock(available=True, device_info=mock_device_info),
|
||||
):
|
||||
assert await hass.config_entries.async_forward_entry_setup(
|
||||
mock_config_entry, "update"
|
||||
)
|
||||
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("update.none_firmware")
|
||||
assert state is not None
|
||||
|
@ -275,9 +274,8 @@ async def test_update_entity_dashboard_not_available_startup(
|
|||
),
|
||||
):
|
||||
await async_get_dashboard(hass).async_refresh()
|
||||
assert await hass.config_entries.async_forward_entry_setup(
|
||||
mock_config_entry, "update"
|
||||
)
|
||||
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# We have a dashboard but it is not available
|
||||
state = hass.states.get("update.none_firmware")
|
||||
|
@ -362,9 +360,8 @@ async def test_update_entity_not_present_without_dashboard(
|
|||
"homeassistant.components.esphome.update.DomainData.get_entry_data",
|
||||
return_value=Mock(available=True, device_info=mock_device_info),
|
||||
):
|
||||
assert await hass.config_entries.async_forward_entry_setup(
|
||||
mock_config_entry, "update"
|
||||
)
|
||||
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("update.none_firmware")
|
||||
assert state is None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue