Repository navigation
Keep sync process wait within its timeout - #50
Open
vincent0426 wants to merge 2 commits into
Open
vincent0426 wants to merge 2 commits into
vincent0426 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The wait deadline is not enforced end to end, since token acquisition, lock waiting, and per-I/O HTTP timeouts can let status checks exceed the caller’s timeout.
2 open issues
What changed in this PR
This PR addresses synchronous sandbox process waits overrunning their timeout after default HTTP read timeouts were disabled.
Changes:
- Passes the remaining wait budget to each synchronous status request.
- Handles HTTP timeout exceptions within the wait loop.
- Adds a regression test for the request’s read-timeout budget and preserved error cause.
| File | Description |
|---|---|
| tests/sandbox/test_process.py | Tests the remaining read-timeout budget and timeout error cause. |
| baseten/sandbox/_process.py | Applies per-check timeouts and handles HTTP timeout exceptions. |
Review effort: Balanced
Comment on lines
+383
to
+384
| time_left = timedelta(seconds=max(deadline - time.monotonic(), 0)) | ||
| api_context = self._context.api_with_timeout(time_left) |
Comment on lines
+383
to
+384
| time_left = timedelta(seconds=max(deadline - time.monotonic(), 0)) | ||
| api_context = self._context.api_with_timeout(time_left) |
Author
|
Both true. This PR fixes a status check that hangs forever. A token fetch is still capped at its own 30s, and httpx timeouts are per read, so it can still run over a bit in those cases. A hard end-to-end deadline would need changes in the token source too, so I'd rather do that separately. |
This branch has not been deployed
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.

🚀 What
Sync
process.wait(timeout=2s)could take ~15s to time out if one status check got stuck. Async times out at 2s like it should.💻 How
The sync loop only checked the deadline between checks, and after #40 a check has no read timeout. So one slow check could hold it for as long as the server took.
Async is fine because
asyncio.timeoutjust cancels the stuck check. Sync can't do that, so now each check gets whatever time is left as its timeout (usingapi_with_timeout, same as the multipart abort).🔬 Testing
Added
test_wait_bounds_each_check_by_the_time_left, fails without this change.Local server where every other status check hangs for 15s,
wait(timeout=2s):