Reduce latency to connect websocket writer (#111559)

Reduce latancy to connect websocket writer

Use an eager start task to start the writer
This commit is contained in:
J. Nick Koston 2024-02-26 15:52:53 -10:00 committed by GitHub
parent 321295a872
commit ebdfff4037
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -16,6 +16,7 @@ from homeassistant.const import EVENT_HOMEASSISTANT_STOP
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.event import async_call_later
from homeassistant.util.async_ import create_eager_task
from homeassistant.util.json import json_loads
from .auth import AUTH_REQUIRED_MESSAGE, AuthPhase
@ -336,7 +337,7 @@ class WebSocketHandler:
# We only start the writer queue after the auth phase is completed
# since there is no need to queue messages before the auth phase
self._connection = connection
self._writer_task = asyncio.create_task(self._writer(send_bytes_text))
self._writer_task = create_eager_task(self._writer(send_bytes_text))
hass.data[DATA_CONNECTIONS] = hass.data.get(DATA_CONNECTIONS, 0) + 1
async_dispatcher_send(hass, SIGNAL_WEBSOCKET_CONNECTED)