Switched JSON serialization to orjson for faster encoding and decoding.
CI / Formatting (push) Failing after 4s
CI / Linting (push) Successful in 4s
CI / Tests (Python 3.12) (push) Successful in 12s
CI / Tests (Python 3.13) (push) Successful in 12s
CI / Tests (Python 3.14) (push) Successful in 10s
CI / Type Checking (push) Successful in 9s
CI / Spelling (push) Successful in 5s
Audit / Dependencies (push) Successful in 7s
CI / Formatting (push) Failing after 4s
CI / Linting (push) Successful in 4s
CI / Tests (Python 3.12) (push) Successful in 12s
CI / Tests (Python 3.13) (push) Successful in 12s
CI / Tests (Python 3.14) (push) Successful in 10s
CI / Type Checking (push) Successful in 9s
CI / Spelling (push) Successful in 5s
Audit / Dependencies (push) Successful in 7s
This commit is contained in:
@@ -16,11 +16,11 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
import aiohttp
|
||||
import orjson
|
||||
from aiohttp import ContentTypeError
|
||||
from markupsafe import escape as _escape_html
|
||||
|
||||
@@ -38,7 +38,7 @@ def _extract_error(text: str) -> str:
|
||||
:return: The extracted error string.
|
||||
"""
|
||||
try:
|
||||
data = json.loads(text)
|
||||
data = orjson.loads(text)
|
||||
except (ValueError, TypeError):
|
||||
return text
|
||||
if isinstance(data, dict):
|
||||
@@ -256,7 +256,7 @@ class OwncastClient:
|
||||
self._logger.debug("POST %s -> %d", endpoint, response.status)
|
||||
if response.content_type == "application/json":
|
||||
try:
|
||||
result = await response.json()
|
||||
result = await response.json(loads=orjson.loads)
|
||||
except (ValueError, ContentTypeError):
|
||||
text = await response.text()
|
||||
self._logger.error(f"Invalid JSON on POST {endpoint}: {text}")
|
||||
@@ -314,7 +314,7 @@ class OwncastClient:
|
||||
raise OwncastError(response.status, message)
|
||||
self._logger.debug("GET %s -> %d", endpoint, response.status)
|
||||
try:
|
||||
result = await response.json()
|
||||
result = await response.json(loads=orjson.loads)
|
||||
except (ValueError, ContentTypeError):
|
||||
text = await response.text()
|
||||
self._logger.error(f"Invalid JSON on GET {endpoint}: {text}")
|
||||
|
||||
Reference in New Issue
Block a user