feat(await): add optional timeout and poll_completion to await_completion#62
Merged
HonestMajority merged 2 commits intomainfrom Mar 17, 2026
Merged
Conversation
Add an optional `timeout: Option<Duration>` parameter to `await_completion` so callers can limit how long they wait for a job to reach a terminal state. When the timeout elapses, a new `JobError::TimedOut` is returned. Passing `None` preserves the original indefinite-wait behaviour. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bodymindarts
approved these changes
Mar 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
timeout: Option<Duration>parameter toawait_completion— if the timeout expires before the job reaches a terminal state, returnsJobError::TimedOutpoll_completionconvenience method — returns the terminal state immediately if done, orNoneif still runningJobError::TimedOut(JobId)error variantMotivation
await_completion(added in #59) blocks indefinitely if a job never completes. Callers need a way to limit how long they wait. Additionally, some callers want a non-blocking check without subscribing to notifications.Changes
await_completiontimeout (src/lib.rs)await_completion(&self, id: JobId, timeout: Option<Duration>)Nonepreserves existing behavior (wait indefinitely)Some(duration)wraps the notification wait withtokio::time::timeoutJobError::TimedOut(id)poll_completion(src/lib.rs)poll_completion(&self, id: JobId) -> Result<Option<JobTerminalState>, JobError>terminal_state()Error type (
src/error.rs)TimedOut(JobId)variant toJobErrorTests (
tests/job.rs)await_completiontests to passNonefor backward compattest_await_completion_timeout— verifiesTimedOuterror on expirytest_poll_completion— verifiesNonefor running jobs,Some(Completed)for finished jobsTest plan
NoneNonefor in-progress,Some(Completed)for finished🤖 Generated with Claude Code