348 files
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
from pathlib import Path
|
||||
@@ -1035,6 +1036,20 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
|
||||
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
|
||||
hass.data.get(_WS_WRITE_LOCKS_KEY, {}).pop(entry.entry_id, None)
|
||||
|
||||
# When the last WashData entry is removed, tear down the shared panel/sidebar
|
||||
# so no stale registration flags or sidebar entry linger.
|
||||
if not hass.data.get(DOMAIN):
|
||||
|
||||
Reference in New Issue
Block a user