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:
parent
321295a872
commit
ebdfff4037
1 changed files with 2 additions and 1 deletions
|
@ -16,6 +16,7 @@ from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
||||||
from homeassistant.core import Event, HomeAssistant, callback
|
from homeassistant.core import Event, HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
from homeassistant.helpers.event import async_call_later
|
from homeassistant.helpers.event import async_call_later
|
||||||
|
from homeassistant.util.async_ import create_eager_task
|
||||||
from homeassistant.util.json import json_loads
|
from homeassistant.util.json import json_loads
|
||||||
|
|
||||||
from .auth import AUTH_REQUIRED_MESSAGE, AuthPhase
|
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
|
# We only start the writer queue after the auth phase is completed
|
||||||
# since there is no need to queue messages before the auth phase
|
# since there is no need to queue messages before the auth phase
|
||||||
self._connection = connection
|
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
|
hass.data[DATA_CONNECTIONS] = hass.data.get(DATA_CONNECTIONS, 0) + 1
|
||||||
async_dispatcher_send(hass, SIGNAL_WEBSOCKET_CONNECTED)
|
async_dispatcher_send(hass, SIGNAL_WEBSOCKET_CONNECTED)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue