mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-20 22:38:02 +00:00
Use orjson when already installed or with speedups extra (#466)
* Use orjson when already installed * Use orjson when already installed * fix patch target * fix patch target * add speedups extra * Update README.md * Update README.md
This commit is contained in:
@@ -12,13 +12,14 @@ http://www.apache.org/licenses/LICENSE-2.0
|
||||
import asyncio
|
||||
import contextlib
|
||||
import errno
|
||||
import json
|
||||
import logging
|
||||
import struct
|
||||
from pprint import pformat as pf
|
||||
from typing import Dict, Generator, Optional, Union
|
||||
|
||||
from .exceptions import SmartDeviceException
|
||||
from .json import dumps as json_dumps
|
||||
from .json import loads as json_loads
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
_NO_RETRY_ERRORS = {errno.EHOSTDOWN, errno.EHOSTUNREACH, errno.ECONNREFUSED}
|
||||
@@ -64,7 +65,7 @@ class TPLinkSmartHomeProtocol:
|
||||
self.query_lock = asyncio.Lock()
|
||||
|
||||
if isinstance(request, dict):
|
||||
request = json.dumps(request)
|
||||
request = json_dumps(request)
|
||||
assert isinstance(request, str)
|
||||
|
||||
timeout = TPLinkSmartHomeProtocol.DEFAULT_TIMEOUT
|
||||
@@ -96,7 +97,7 @@ class TPLinkSmartHomeProtocol:
|
||||
|
||||
buffer = await self.reader.readexactly(length)
|
||||
response = TPLinkSmartHomeProtocol.decrypt(buffer)
|
||||
json_payload = json.loads(response)
|
||||
json_payload = json_loads(response)
|
||||
if debug_log:
|
||||
_LOGGER.debug("%s << %s", self.host, pf(json_payload))
|
||||
|
||||
|
Reference in New Issue
Block a user