Start live history/logbook with eager tasks (#113779)

This commit is contained in:
J. Nick Koston 2024-03-18 21:00:51 -10:00 committed by GitHub
parent e3ae66ca64
commit 8b9a8a33f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View file

@ -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

View file

@ -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