Paginate list responses when multi requests are disabled (#1838)
Some checks are pending
CI / Perform Lint Checks (3.15) (push) Waiting to run
CI / Python 3.11 on macos-latest (push) Blocked by required conditions
CI / Python 3.12 on macos-latest (push) Blocked by required conditions
CI / Python 3.13 on macos-latest (push) Blocked by required conditions
CI / Python 3.14 on macos-latest (push) Blocked by required conditions
CI / Python 3.15 on macos-latest (push) Blocked by required conditions
CI / Python 3.11 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.12 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.13 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.14 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.15 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.11 on windows-latest (push) Blocked by required conditions
CI / Python 3.12 on windows-latest (push) Blocked by required conditions
CI / Python 3.13 on windows-latest (push) Blocked by required conditions
CI / Python 3.14 on windows-latest (push) Blocked by required conditions
CI / Python 3.15 on windows-latest (push) Blocked by required conditions
CodeQL Checks / Analyze (python) (push) Waiting to run

Drop the separate `step == 1` send loop. With batching off, the requests
go through the existing loop at the end of the method, which now
paginates. That loop also handles lists requeried after an error in a
batch, which were truncated the same way with no timeout involved.

---------

Co-authored-by: ZeliardM <140266236+ZeliardM@users.noreply.github.com>
This commit is contained in:
DevilRange
2026-11-21 01:08:55 +02:00
committed by GitHub
parent 1b4e540ae6
commit 7a5b3a2658
2 changed files with 49 additions and 16 deletions

View File

@@ -224,18 +224,9 @@ class SmartProtocol(BaseProtocol):
# Break the requests down as there can be a size limit
step = self._multi_request_batch_size
if step == 1:
# If step is 1 do not send request batches
for request in multi_requests:
method = request["method"]
req = self.get_smart_request(method, request.get("params"))
resp = await self._transport.send(req)
self._handle_response_error_code(
resp, method, raise_on_error=raise_on_error
)
multi_result[method] = resp["result"]
return multi_result
for batch_num, i in enumerate(range(0, end, step)):
# Batching is off, so the loop at the end sends each request on its own
multi_requests = []
for batch_num, i in enumerate(range(0, len(multi_requests), step)):
requests_step = multi_requests[i : i + step]
smart_params = {"requests": requests_step}
@@ -254,8 +245,7 @@ class SmartProtocol(BaseProtocol):
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.
# list requests together) so disable batching.
self._multi_request_batch_size = 1
raise _RetryableError(
"Timeout during multi request, multi requests disabled"
@@ -328,7 +318,12 @@ class SmartProtocol(BaseProtocol):
self._handle_response_error_code(
resp, method, raise_on_error=raise_on_error
)
multi_result[method] = resp.get("result")
result = resp.get("result")
if iterate_list_pages and result:
await self._handle_response_lists(
result, method, params, retry_count=retry_count
)
multi_result[method] = result
return multi_result
async def _execute_query(