Reject non-positive parallel processor limits - #3013
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d2ce14743
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if max_requests_per_minute <= 0: | ||
| raise ValueError("max_requests_per_minute must be positive") |
There was a problem hiding this comment.
Reject request rates below one
When a direct caller passes a positive fractional rate such as 0.5—which is permitted by the float annotation and this validation—the request capacity is initialized and permanently capped below 1, so the scheduling condition available_request_capacity >= 1 can never succeed and a nonempty job runs indefinitely. Reject values below 1, or adjust the token-bucket logic to support fractional request rates.
Useful? React with 👍 / 👎.
Summary
Motivation
process_api_requests_from_file()assumes its scheduling limits are positive, but currently accepts zero and negative values.That can make the processor fail to terminate:
max_requests_per_minute <= 0means request capacity never reaches the>= 1scheduling condition.max_tokens_per_minute <= 0means token capacity cannot satisfy a positive request cost.max_attempts == 0is decremented to-1before the first call; if that call fails,if self.attempts_left:treats the negative value as truthy and requeues the request indefinitely.Failing at the processor boundary prevents these hang/infinite-retry states without changing normal throttling behavior.
Closes #3012.
Validation
max_attempts >= 1-> existing behavior unchangedValueErrorValueErrormax_attempts < 1-> immediateValueErrorSelf-review
Maintainers may modify the branch if needed.