feat(client): add request rate limiting - #823
Conversation
|
@NiklasReisser Given your recent work around server behavior and application-facing semantics, could you review the request-rate-limiting API and concurrency behavior here? |
|
@amorelettronico you previously tested the pure-Python client on CPU 414-5H and CPU416-2 hardware. Could you run a small real-PLC smoke test of the opt-in rate limiter on an S7-400 when convenient?\n\nThe useful check would be a low fixed rate (for example 5 requests/second), confirming reads still succeed and are spaced as configured, followed by disabling the limiter and confirming normal behavior returns. No production load test or sensitive PLC data is needed. |
|
Hi @gijzelaerr Hardware smoke test — S7-416-2 DPTested PR #823 against a Siemens S7-416-2 DP using DB15 as a dedicated test DB. Configuration
DB read
Rate limiter — 5 requests/sec
Limiter disabled
ConclusionThe rate limiter behaves as expected on the S7-416-2 DP with a real PLC connection. PR #823 smoke test: PASS. |
|
Thanks @amorelettronico — this covers the requested hardware smoke test: successful reads, approximately 200 ms spacing at 5 requests/sec, and normal timing with the limiter disabled. @NiklasReisser the review findings were addressed in cd631ed and replied to inline. All current checks pass, and the S7-416-2 DP hardware test now passes too. Could you take another look and submit a review? The existing review request is still pending. |
Summary
A multi-variable PDU counts as one request, while chunked and multi-packet operations count each actual PDU. Model-specific defaults are intentionally not inferred: the limiter is disabled by default and users choose a rate appropriate for their PLC and workload.
Silent drops are unsafe at the PDU boundary because the surrounding client operation would wait for a response to a request that was never sent. The non-blocking behavior therefore raises
S7RateLimitErrorimmediately.The branch includes current
masterthrough a merge commit.Validation
uv run --frozen pre-commit run --all-filesuv run --frozen --extra test --extra s7commplus pytest -q(1,902 passed, 78 skipped)uv build --no-sourcesFixes #628