1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Initial orjson support (#72754)

This commit is contained in:
J. Nick Koston
2022-05-31 09:18:11 -10:00
committed by GitHub
parent a3e1b285cf
commit d9d22a9556
18 changed files with 127 additions and 67 deletions

View File

@@ -14,6 +14,7 @@ from aiohttp import web
from aiohttp.hdrs import CONTENT_TYPE, USER_AGENT
from aiohttp.web_exceptions import HTTPBadGateway, HTTPGatewayTimeout
import async_timeout
import orjson
from homeassistant import config_entries
from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE, __version__
@@ -97,6 +98,7 @@ def _async_create_clientsession(
"""Create a new ClientSession with kwargs, i.e. for cookies."""
clientsession = aiohttp.ClientSession(
connector=_async_get_connector(hass, verify_ssl),
json_serialize=lambda x: orjson.dumps(x).decode("utf-8"),
**kwargs,
)
# Prevent packages accidentally overriding our default headers