diff --git a/homeassistant/components/history/websocket_api.py b/homeassistant/components/history/websocket_api.py index 1f1c5064c5a..6eb1fec3416 100644 --- a/homeassistant/components/history/websocket_api.py +++ b/homeassistant/components/history/websocket_api.py @@ -36,6 +36,7 @@ from homeassistant.helpers.event import ( async_track_state_change_event, ) from homeassistant.helpers.json import json_bytes +from homeassistant.util.async_ import create_eager_task import homeassistant.util.dt as dt_util from .const import EVENT_COALESCE_TIME, MAX_PENDING_HISTORY_STATES @@ -536,7 +537,7 @@ async def ws_stream( # Unsubscribe happened while sending historical states return - live_stream.task = asyncio.create_task( + live_stream.task = create_eager_task( _async_events_consumer( subscriptions_setup_complete_time, connection, @@ -546,7 +547,7 @@ async def ws_stream( ) ) - live_stream.wait_sync_task = asyncio.create_task( + live_stream.wait_sync_task = create_eager_task( get_instance(hass).async_block_till_done() ) await live_stream.wait_sync_task diff --git a/homeassistant/components/logbook/websocket_api.py b/homeassistant/components/logbook/websocket_api.py index 4e4732c0d0e..6d976a50240 100644 --- a/homeassistant/components/logbook/websocket_api.py +++ b/homeassistant/components/logbook/websocket_api.py @@ -18,6 +18,7 @@ from homeassistant.components.websocket_api.connection import ActiveConnection from homeassistant.core import CALLBACK_TYPE, Event, HomeAssistant, callback from homeassistant.helpers.event import async_track_point_in_utc_time from homeassistant.helpers.json import json_bytes +from homeassistant.util.async_ import create_eager_task import homeassistant.util.dt as dt_util from .const import DOMAIN @@ -395,7 +396,7 @@ async def ws_event_stream( # Unsubscribe happened while sending historical events return - live_stream.task = asyncio.create_task( + live_stream.task = create_eager_task( _async_events_consumer( subscriptions_setup_complete_time, connection, @@ -405,7 +406,7 @@ async def ws_event_stream( ) ) - live_stream.wait_sync_task = asyncio.create_task( + live_stream.wait_sync_task = create_eager_task( get_instance(hass).async_block_till_done() ) await live_stream.wait_sync_task