Python(fix): add channel timeout#609
Merged
Merged
Conversation
18f62e5 to
a276406
Compare
Contributor
|
Python docs preview: https://sift-stack.github.io/sift/python/pr-609/ Deployed from |
Use dict.get for the NotRequired "timeout" key so pyright's reportTypedDictNotRequiredAccess no longer fails static-checks. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
solidiquis
approved these changes
Jun 3, 2026
wei-qlu
reviewed
Jun 3, 2026
| timeout = getattr(client, "sync_call_timeout", None) | ||
| future = asyncio.run_coroutine_threadsafe(coro, loop) | ||
| try: | ||
| return future.result(timeout=timeout) |
Contributor
There was a problem hiding this comment.
It seems like this timeout cap (75s) wrapping the coroutine will abort long-running sync processes like wait_until_complete / wait_and_download even if they're still polling, or if the user passes in a larger timeout_sec arg
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
Synchronous SDK calls could hang indefinitely. A stalled gRPC connection, or a call issued after the client's background event loop had stopped during teardown, left the calling thread blocked forever because neither the RPC nor the blocking wait had a deadline. This adds a default request deadline plus two backstops so a stalled or post-shutdown call fails with a clear error instead of hanging.
Changes
methodConfig.timeout), alongside the existing retry policy. A stalled call fails withDEADLINE_EXCEEDEDrather than hanging. Configurable per connection viaGrpcConfig(request_timeout=...), overridable per call, and disabled by passingNone..result()now uses a deadline (RPC timeout plus a margin) and raisesTimeoutErrorafter cancelling the request. The gRPC deadline fires first, so this only trips if that fails.RuntimeErrorinstead of scheduling onto a dead loop and blocking.Testing
_internalunit suite passes, including new coverage for the sync deadline and the post-close guard.60sdefault, explicit override honored, omitted when disabled.Notes
The default of 60s sits above the retry budget (5 attempts, 5s max backoff). The service-config timeout applies to all methods via the wildcard matcher; this is safe because high-throughput streaming runs through the Rust stream bindings on a separate connection, not this channel.