Fix DPSJob.wait_for_completion() race condition with initial delay#127
Merged
Conversation
Add a default 5-second initial delay before the first status check to allow
newly submitted jobs to appear in the OpenSearch database. This fixes the issue
where wait_for_completion() would return immediately with incorrect status
('Deleted') if called right after job submission.
Changes:
- Add time module import
- Add initial_delay_seconds parameter (default 5) to wait_for_completion()
- Improve status check logic to handle any non-terminal state by retrying
- Update docstring with parameter documentation
Fixes issue #126
https://claude.ai/code/session_01KEDGhwSuoY9N5inWR9bk5u
grallewellyn
approved these changes
Apr 30, 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
Fixes the race condition in
DPSJob.wait_for_completion()where the method would return immediately with an incorrect "Deleted" status if called right after job submission, before the job appears in the OpenSearch database.Problem
wait_for_completion()is called immediately after submission, the API returns an unexpected status before the job appears in the databaseSolution
Implemented an initial delay mechanism:
initial_delay_secondsparameter (default 5 seconds) towait_for_completion()Changes
timemodule importinitial_delay_secondsparameter with default value of 5 secondsTesting
Users can now reliably call
wait_for_completion()immediately after job submission:To disable the initial delay for existing jobs (where status is already available):
Related Issues
Fixes #126
https://claude.ai/code/session_01KEDGhwSuoY9N5inWR9bk5u
Generated by Claude Code