Repository navigation
fix(python-sdk): enforce request timeouts as whole-request deadlines - #1977
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
pyqwest's httpx adapter approximates an operation timeout as the sum of the httpx read and write phases, so every httpx.Timeout(N) the SDK built was enforced at ~2N (#1881). Map the deadline once in the shared transports (e2b.deadline) and budget retries against the same number; drop the stale code-interpreter comment and let request_timeout=0 disable the timeout there. Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
🦋 Changeset detectedLatest commit: 89a7d30 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Package ArtifactsBuilt from 5715099. Download artifacts from this workflow run. JS SDK ( npm install ./e2b-dockerfile-utils-0.1.1-devin-1791887064-python-request-deadline.0.tgz ./e2b-2.55.1-devin-1791887064-python-request-deadline.0.tgzCLI ( npm install ./e2b-cli-2.21.3-devin-1791887064-python-request-deadline.0.tgzCode Interpreter JS SDK ( npm install ./e2b-code-interpreter-2.8.4-devin-1791887064-python-request-deadline.0.tgzDesktop JS SDK ( npm install ./e2b-desktop-2.4.1-devin-1791887064-python-request-deadline.0.tgzPython SDK ( pip install ./e2b_dockerfile_utils-0.1.0+devin.1791887064.python.request.deadline-py3-none-any.whl ./e2b-2.55.1+devin.1791887064.python.request.deadline-py3-none-any.whlCode Interpreter Python SDK ( pip install ./e2b_code_interpreter-2.10.5+devin.1791887064.python.request.deadline-py3-none-any.whlDesktop Python SDK ( pip install ./e2b_desktop-2.6.1+devin.1791887064.python.request.deadline-py3-none-any.whl |
Summary
Fixes #1881 (
run_code(timeout=N)enforced at ~2N) at the layer that owns the deadline, superseding the per-call-sitewrite=0approach in #1886.pyqwest's httpx adapter has no deadline input:
convert_timeoutapproximates an operation timeout asread + write(curioswitch/pyqwest#220) and ignoresconnect/pool. Everyhttpx.Timeout(x)the SDK builds (ApiClient'sTimeout(config.request_timeout), envd file ops, the volume client, template uploads, code-interpreter'sTimeout(timeout, connect=request_timeout)) was therefore enforced at2x, whileRetryableTransport._request_deadlinebudgetedmin(phases)=x.New leaf module
e2b/deadline.py(import-cycle-free soe2b.retrycan use it) defines the SDK rule once — thereadphase ofhttpx.Timeoutis the whole-request deadline:get_httpx_transport(sync/async) and the inline template-upload transports now buildPyqwestDeadlineTransport/AsyncPyqwestDeadlineTransport, so all shared httpx consumers getTimeout(x)→xwith no call-site changes._request_deadlineine2b/retry.pyusesrequest_deadline, so the retry budget equals the enforced deadline (Timeout(300, connect=60)→ 300, not 60).request_timeout=0onrun_code/create_code_contextnow disables the timeout viaConnectionConfig.get_request_timeoutinstead ofrequest_timeout or default(pre-existing nit from the fix(code-interpreter): abort Jupyter requests at the requested deadline #1886 review).The rewrite deliberately encodes pyqwest's current sum rule in one place; once pyqwest exposes an explicit operation-timeout extension,
with_request_deadlinebecomes a one-line change.Tests:
tests/test_request_deadline.py— pure mapping/retry-budget cases plus a stalling local HTTP server proving sync and asyncApiClient(request_timeout) and envd (Timeout(d, connect=60)) requests fail at~drather than2d, andTimeout(None)still waits.Link to Devin session: https://app.devin.ai/sessions/8c713b7050c949b892adfbbfa9fd4525
Open in Devin Desktop: https://app.devin.ai/desktop/session/8c713b7050c949b892adfbbfa9fd4525?variant=devin
Requested by: @mishushakov