From 4e477eee3386c45471a8a3c1978456dcd58eafa7 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 16 Feb 2023 13:14:22 -0500 Subject: [PATCH] Don't dangle tasks in async decorator for WS API --- homeassistant/components/websocket_api/decorators.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/homeassistant/components/websocket_api/decorators.py b/homeassistant/components/websocket_api/decorators.py index 296271c7cf..3c5ab1584a 100644 --- a/homeassistant/components/websocket_api/decorators.py +++ b/homeassistant/components/websocket_api/decorators.py @@ -1,7 +1,6 @@ """Decorators for the Websocket API.""" from __future__ import annotations -import asyncio from collections.abc import Callable from functools import wraps from typing import Any @@ -42,7 +41,7 @@ def async_response( """Schedule the handler.""" # As the webserver is now started before the start # event we do not want to block for websocket responders - asyncio.create_task(_handle_async_response(func, hass, connection, msg)) + hass.async_create_task(_handle_async_response(func, hass, connection, msg)) return schedule_handler