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
pull/115546/head
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
1 changed files with 5 additions and 12 deletions

View File

@ -2578,10 +2578,11 @@ class EntityRegistryDisabledHandler:
self._remove_call_later = async_call_later(
self.hass,
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."""
self._remove_call_later = None
to_reload = self.changed
@ -2594,16 +2595,8 @@ class EntityRegistryDisabledHandler:
),
", ".join(to_reload),
)
await asyncio.gather(
*(
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
)
)
for entry_id in to_reload:
self.hass.config_entries.async_schedule_reload(entry_id)
@callback