Make ConfigEntry.async_shutdown a callback (#111027)

Nothing needed to be awaited here and this generated a task per config
entry at shutdown
This commit is contained in:
J. Nick Koston 2024-02-20 20:38:24 -06:00 committed by GitHub
parent 17ba96ffdb
commit 94e372a345
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -603,7 +603,8 @@ class ConfigEntry:
)
return self._setup_again_job
async def async_shutdown(self) -> None:
@callback
def async_shutdown(self) -> None:
"""Call when Home Assistant is stopping."""
self.async_cancel_retry_setup()
@ -1409,15 +1410,8 @@ class ConfigEntries:
async def _async_shutdown(self, event: Event) -> None:
"""Call when Home Assistant is stopping."""
await asyncio.gather(
*(
asyncio.create_task(
entry.async_shutdown(),
name=f"config entry shutdown {entry.title} {entry.domain} {entry.entry_id}",
)
for entry in self._entries.values()
)
)
for entry in self._entries.values():
entry.async_shutdown()
await self.flow.async_shutdown()
async def async_initialize(self) -> None: