{{ message }}
Repository navigation
Reject a non-positive rate in constant_throughput() - #3534
Merged
cyberw merged 1 commit intoOct 3, 2026
Merged
Conversation
constant_throughput(-0.1) turned into constant_pacing(-10), whose max(0, ...) silently returned a zero wait, so the load ran as fast as possible instead of raising or throttling. constant_throughput(0) raised a bare ZeroDivisionError that named neither the function nor the argument.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Reject a non-positive rate in
constant_throughput(), using the same guardpoisson()inthis module already has.
Without it:
constant_throughput(-0.1)becomesconstant_pacing(-10), whosemax(0, wait_time - run_time)returns
0every time, so the load runs flat out with no warning — the opposite of what wasconfigured;
constant_throughput(0)raises a bareZeroDivisionError: division by zerowhile the locustfileis imported, naming neither the function nor the argument.
constant_throughput()is documented as the mathematical inverse ofconstant_pacing()and thefixed-rate sibling of
poisson(), so the positive-rate requirement belongs in the same place.Fixes #3533
How was it checked
On
masteratd7842f50, before the change (baseline file restored fromHEAD):after the change:
No other call site in the repository passes a non-positive rate, and the documented examples
(
constant_throughput(0.1),constant_throughput(2),constant_throughput(10)) are unaffected.Drafted with AI assistance in this session; no human reviewed it before submission.