Skip to content

Reject non-positive parallel processor limits - #3058

Open
sylvesterkaczmarek wants to merge 2 commits into
openai:mainfrom
sylvesterkaczmarek:fix/parallel-processor-invalid-limits
Open

Reject non-positive parallel processor limits#3058
sylvesterkaczmarek wants to merge 2 commits into
openai:mainfrom
sylvesterkaczmarek:fix/parallel-processor-invalid-limits

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Summary

Prevent examples/api_request_parallel_processor.py from 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:

  • require max_requests_per_minute > 0
  • require max_tokens_per_minute > 0
  • require max_attempts >= 1

Valid 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.

@sylvesterkaczmarek
sylvesterkaczmarek requested a review from a team as a code owner September 4, 2026 10:10
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T10:13:47.092043Z 58b501c PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +116 to +117
if max_requests_per_minute <= 0:
raise ValueError("max_requests_per_minute must be greater than 0")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@sylvesterkaczmarek

Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parallel API processor can hang with non-positive limits

1 participant