Migrate EntityRegistryDisabledHandler to use async_schedule_reload (#115544)

async_schedule_reload ensures that any setup retries are cancelled
before executing the reload. Its unlikely in this case but its
still possible
This commit is contained in:
J. Nick Koston 2024-04-13 10:30:59 -10:00 committed by GitHub
parent 1a8857aa2e
commit 08e2b655be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2578,10 +2578,11 @@ class EntityRegistryDisabledHandler:
self._remove_call_later = async_call_later( self._remove_call_later = async_call_later(
self.hass, self.hass,
RELOAD_AFTER_UPDATE_DELAY, RELOAD_AFTER_UPDATE_DELAY,
HassJob(self._handle_reload, cancel_on_shutdown=True), HassJob(self._async_handle_reload, cancel_on_shutdown=True),
) )
async def _handle_reload(self, _now: Any) -> None: @callback
def _async_handle_reload(self, _now: Any) -> None:
"""Handle a reload.""" """Handle a reload."""
self._remove_call_later = None self._remove_call_later = None
to_reload = self.changed to_reload = self.changed
@ -2594,16 +2595,8 @@ class EntityRegistryDisabledHandler:
), ),
", ".join(to_reload), ", ".join(to_reload),
) )
for entry_id in to_reload:
await asyncio.gather( self.hass.config_entries.async_schedule_reload(entry_id)
*(
asyncio.create_task(
self.hass.config_entries.async_reload(entry_id),
name="config entry reload {entry.title} {entry.domain} {entry.entry_id}",
)
for entry_id in to_reload
)
)
@callback @callback