INNER CODE UNIT · Python
async_unload_entry
3dg1luk43/ha_washdata · custom_components/ha_washdata/__init__.py:1405
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
hass.data.get(FORWARDED_ENTRIES_KEY, set()).discard(entry.entry_id)
manager = hass.data[DOMAIN].pop(entry.entry_id)
await manager.async_shutdown()
# Settle registry: mark any still-RUNNING tasks for this entry as
# cancelled so they don't appear as zombies after reload.
from . import task_registry as _task_registry
_cancelled_tasks = _task_registry.get_registry(hass).cancel_entry_tasks(entry.entry_id)
# Drain cancelled WS-spawned tasks so their finally blocks (lock releases)
# complete before we remove the write lock below.
if _cancelled_tasks:
await asyncio.gather(*_cancelled_tasks, return_exceptions=True)
# Release the per-entry write lock so it doesn't block the next setup.
from .ws_api import _WS_WRITE_LOCKS_KEY, async_clear_history_import