Add poll_async_job helper#185
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f543ae16f2
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6123b0ccc
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9209b86e6a
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f473c955a6
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47671a62e4
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e82b079895
ℹ️ 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".
Drops the separate dispatch on the initial request response by treating it as the first iteration of poll_async_job. Trades one extra poll_interval sleep on the not-yet-ready path for ~12 fewer lines and a single status-handling code path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Timeouts now surface as AsyncJobError with a synthetic status="TIMEOUT" sentinel, letting callers distinguish them from server-side failures via e.status without a separate exception class. Also moves the deadline check after each poll instead of at the top of the next iteration, so a job that completes during the final sleep is honored instead of being lost to a timeout. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Lets callers hand the helper a kick-off response to consume as iter 1 in place of the first check_status() call. save_report uses it so its _check closure no longer needs to branch between request() and check_status() based on iteration count. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| pending = initial_status | ||
| while True: | ||
| if pending is not None: | ||
| status, pending = pending, None |
There was a problem hiding this comment.
nit: this seems like a weird way of doing this, not sure if there is a better way
|
|
||
| Returns the terminal status dict. | ||
| """ | ||
| in_progress = set(in_progress_statuses) |
There was a problem hiding this comment.
nit: should the constants be sets?
Make the default status collections frozensets so membership checks don't rebuild sets on every call, and drop the per-call set() wrapping. Restructure the poll loop to seed the first status and fetch the next one at the end of the body, removing the pending/swap dance. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: be2bae68f7
ℹ️ 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 value in completed_statuses: | ||
| return status |
There was a problem hiding this comment.
Check the deadline before accepting completion
When a poll response arrives after poll_time has already elapsed, this branch still returns it as successful because the deadline is only checked later for in-progress statuses. For example, with an initial IN_PROGRESS, poll_time=1, and a delayed/overslept next check_status() returning COMPLETED after the deadline, callers get success despite the documented maximum wait; the fresh evidence is that this revision still returns completed statuses before any post-poll deadline check.
Useful? React with 👍 / 👎.
Reframes poll_time in the docstring as the budget for time spent waiting between polls rather than a hard wall-clock ceiling, matching the implementation that honors a terminal status already returned by a poll. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds a small polling utility for async-job status endpoints.