Skip to content

[codex] Add timeout for vector store file polling#3429

Open
fengjikui wants to merge 2 commits into
openai:mainfrom
fengjikui:codex/vector-file-poll-timeout
Open

[codex] Add timeout for vector store file polling#3429
fengjikui wants to merge 2 commits into
openai:mainfrom
fengjikui:codex/vector-file-poll-timeout

Conversation

@fengjikui

Copy link
Copy Markdown

Summary

  • add max_wait_seconds to vector store file poll, create_and_poll, and upload_and_poll helpers
  • default the helper timeout to 30 minutes, matching files.wait_for_processing()
  • raise a clear RuntimeError instead of waiting forever when a vector store file remains in_progress
  • cover the sync and async timeout paths without making network calls

Fixes #3097

Tests

  • env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy uv run --with pytest --with pytest-asyncio --with respx --with rich pytest -o addopts='' tests/api_resources/vector_stores/test_files.py::TestFiles::test_poll_times_out_for_stuck_in_progress tests/api_resources/vector_stores/test_files.py::TestAsyncFiles::test_poll_times_out_for_stuck_in_progress tests/api_resources/vector_stores/test_files.py::test_create_and_poll_method_in_sync tests/api_resources/vector_stores/test_files.py::test_upload_and_poll_method_in_sync -q
  • uv run --with ruff ruff check src/openai/resources/vector_stores/files.py tests/api_resources/vector_stores/test_files.py
  • uv run --with ruff ruff format --check src/openai/resources/vector_stores/files.py tests/api_resources/vector_stores/test_files.py
  • git diff --check

@fengjikui fengjikui requested a review from a team as a code owner June 23, 2026 18:06

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

Copy link
Copy Markdown

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: cc3bae29e2

ℹ️ 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 +390 to +393
if time.time() - start > max_wait_seconds:
raise RuntimeError(
f"Giving up on waiting for vector store file {file_id} to finish processing after {max_wait_seconds} seconds."
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bound sleep duration by remaining timeout

Because the timeout is checked only before sleeping, a large poll_interval_ms or openai-poll-after-ms value can make the new limit ineffective: for example max_wait_seconds=5 with a 60s poll interval will pass this check and then block for the full 60s before it can raise. Cap the next sleep to the remaining budget, or re-check the deadline before sleeping; the async poll helper mirrors the same pattern.

Useful? React with 👍 / 👎.

@fengjikui

Copy link
Copy Markdown
Author

Follow-up on the Codex P2 timeout review: this is addressed in fe2e152. Both sync and async poll now cap the next sleep with min(poll_interval_ms / 1000, remaining), so a large custom poll interval cannot overshoot max_wait_seconds by a full sleep interval.

I re-ran the focused coverage after checking the current branch:

env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy uv run --with pytest --with pytest-asyncio --with respx --with rich pytest -o addopts='' tests/api_resources/vector_stores/test_files.py::TestFiles::test_poll_times_out_for_stuck_in_progress tests/api_resources/vector_stores/test_files.py::TestFiles::test_poll_limits_sleep_to_remaining_timeout tests/api_resources/vector_stores/test_files.py::TestAsyncFiles::test_poll_times_out_for_stuck_in_progress tests/api_resources/vector_stores/test_files.py::TestAsyncFiles::test_poll_limits_sleep_to_remaining_timeout tests/api_resources/vector_stores/test_files.py::test_create_and_poll_method_in_sync tests/api_resources/vector_stores/test_files.py::test_upload_and_poll_method_in_sync -q
# 8 passed

uv run --with ruff ruff check src/openai/resources/vector_stores/files.py tests/api_resources/vector_stores/test_files.py
# All checks passed!

uv run --with ruff ruff format --check src/openai/resources/vector_stores/files.py tests/api_resources/vector_stores/test_files.py
# 2 files already formatted

git diff --check
# passed

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.

vector_stores.files.upload_and_poll() can hang indefinitely with file status stuck at in_progress

1 participant