Suppress CancelledError in zwave-js unload (#91222)

This commit is contained in:
epenet 2023-04-12 08:09:00 +02:00 committed by GitHub
parent 237faf62ac
commit 4e78bcb236
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ from __future__ import annotations
import asyncio import asyncio
from collections import defaultdict from collections import defaultdict
from collections.abc import Coroutine from collections.abc import Coroutine
from contextlib import suppress
from typing import Any from typing import Any
from async_timeout import timeout from async_timeout import timeout
@ -792,7 +793,11 @@ async def disconnect_client(hass: HomeAssistant, entry: ConfigEntry) -> None:
for task in platform_setup_tasks: for task in platform_setup_tasks:
task.cancel() task.cancel()
await asyncio.gather(listen_task, start_client_task, *platform_setup_tasks) tasks = (listen_task, start_client_task, *platform_setup_tasks)
await asyncio.gather(*tasks, return_exceptions=True)
for task in tasks:
with suppress(asyncio.CancelledError):
await task
if client.connected: if client.connected:
await client.disconnect() await client.disconnect()