mirror of
https://github.com/python-kasa/python-kasa.git
synced 2026-10-26 06:32:58 +00:00
Keep multi requests for smartcam devices after a timeout (#1802)
Some checks failed
CI / Perform Lint Checks (3.14) (push) Has been cancelled
CodeQL Checks / Analyze (python) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.14 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.14 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
CI / Python 3.14 on windows-latest (push) Has been cancelled
Stale / stale (push) Has been cancelled
Some checks failed
CI / Perform Lint Checks (3.14) (push) Has been cancelled
CodeQL Checks / Analyze (python) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.14 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.14 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
CI / Python 3.14 on windows-latest (push) Has been cancelled
Stale / stale (push) Has been cancelled
Smartcam devices do not support sending individual requests, but respond always with `PROTOCOL_FORMAT_ERROR (-40210)`. This commit forces them to always use the multi-request format for requests even after receiving an error where we would otherwise fallback to individual requests.
This commit is contained in:
@@ -103,6 +103,8 @@ class SmartProtocol(BaseProtocol):
|
||||
|
||||
BACKOFF_SECONDS_AFTER_TIMEOUT = 1
|
||||
DEFAULT_MULTI_REQUEST_BATCH_SIZE = 5
|
||||
# True if the device rejects single requests, so batching is never disabled.
|
||||
REQUIRES_MULTIREQUESTS = False
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -248,6 +250,8 @@ class SmartProtocol(BaseProtocol):
|
||||
try:
|
||||
response_step = await self._transport.send(smart_request)
|
||||
except TimeoutError as ex:
|
||||
if self.REQUIRES_MULTIREQUESTS:
|
||||
raise
|
||||
# P300 does not respond to some batched requests (e.g. both child
|
||||
# list requests together) so disable batching. Batch size is never
|
||||
# 1 here as that case sends single requests above.
|
||||
@@ -278,6 +282,7 @@ class SmartProtocol(BaseProtocol):
|
||||
SmartErrorCode.INTERNAL_UNKNOWN_ERROR,
|
||||
}
|
||||
and self._multi_request_batch_size != 1
|
||||
and not self.REQUIRES_MULTIREQUESTS
|
||||
):
|
||||
self._multi_request_batch_size = 1
|
||||
raise _RetryableError(
|
||||
|
||||
Reference in New Issue
Block a user