1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Ensure config entry setup lock is held when removing a config entry (#117086)

This commit is contained in:
J. Nick Koston
2024-05-10 19:47:26 -05:00
committed by GitHub
parent c74c2f3652
commit 2e60e09ba2
2 changed files with 20 additions and 16 deletions

View File

@@ -1621,15 +1621,16 @@ class ConfigEntries:
if (entry := self.async_get_entry(entry_id)) is None:
raise UnknownEntry
if not entry.state.recoverable:
unload_success = entry.state is not ConfigEntryState.FAILED_UNLOAD
else:
unload_success = await self.async_unload(entry_id)
async with entry.setup_lock:
if not entry.state.recoverable:
unload_success = entry.state is not ConfigEntryState.FAILED_UNLOAD
else:
unload_success = await self.async_unload(entry_id)
await entry.async_remove(self.hass)
await entry.async_remove(self.hass)
del self._entries[entry.entry_id]
self._async_schedule_save()
del self._entries[entry.entry_id]
self._async_schedule_save()
dev_reg = device_registry.async_get(self.hass)
ent_reg = entity_registry.async_get(self.hass)