Reduce latency to set up websocket forwarding in hassio (#111558)
Reduce latancy to set up websocket forwarding in hassio Create the tasks eagerly to avoid one iteration of the event loop to connect the proxy
This commit is contained in:
parent
ae2ce99cbd
commit
321295a872
1 changed files with 3 additions and 2 deletions
|
@ -18,6 +18,7 @@ from homeassistant.components.http import HomeAssistantView
|
|||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.typing import UNDEFINED
|
||||
from homeassistant.util.async_ import create_eager_task
|
||||
|
||||
from .const import X_HASS_SOURCE, X_INGRESS_PATH
|
||||
from .http import should_compress
|
||||
|
@ -143,8 +144,8 @@ class HassIOIngress(HomeAssistantView):
|
|||
# Proxy requests
|
||||
await asyncio.wait(
|
||||
[
|
||||
asyncio.create_task(_websocket_forward(ws_server, ws_client)),
|
||||
asyncio.create_task(_websocket_forward(ws_client, ws_server)),
|
||||
create_eager_task(_websocket_forward(ws_server, ws_client)),
|
||||
create_eager_task(_websocket_forward(ws_client, ws_server)),
|
||||
],
|
||||
return_when=asyncio.FIRST_COMPLETED,
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue