Reject non-positive parallel processor limits - #3058
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58b501cbf7
ℹ️ 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 greater than 0") |
There was a problem hiding this comment.
Reject request limits below one
When this coroutine is called directly with 0 < max_requests_per_minute < 1, which the float parameter permits, this validation accepts the value. The scheduler initializes and caps available_request_capacity at that limit, while dispatch requires capacity to be at least 1; after the first input is read, the request therefore remains pending and the loop sleeps forever. Reject sub-one limits or allow the bucket to accumulate enough capacity for one request.
Useful? React with 👍 / 👎.
|
Addressed the sub-unit capacity case. Both request and token rate limits now require at least 1, matching the scheduler thresholds so a positive fractional bucket cannot leave a request pending forever. The example compiles successfully with py_compile. |
Summary
Prevent
examples/api_request_parallel_processor.pyfrom hanging when configured with non-positive request or token limits, or with zero retry attempts.The processor now validates its limits at the processing boundary before opening the input file or creating an HTTP session:
max_requests_per_minute > 0max_tokens_per_minute > 0max_attempts >= 1Valid configurations are unchanged.
Fixes #3012.
Motivation
Non-positive request or token capacities can leave a pending request permanently unable to enter the scheduling path. A zero attempt count is decremented to a negative value before the request is made, and negative integers remain truthy in the retry check, which can cause failed requests to be requeued indefinitely.
Rejecting these configurations immediately gives callers a clear error instead of allowing the processor to stall.