feat(python-sdk): use pyqwest native HTTP/2 connection balancing - #1931
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
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: a5c3bc1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
Package ArtifactsBuilt from 57199b9. Download artifacts from this workflow run. JS SDK ( npm install ./e2b-2.52.1-devin-1790937617-pyqwest-native-balancing.0.tgzCLI ( npm install ./e2b-cli-2.21.1-devin-1790937617-pyqwest-native-balancing.0.tgzCode Interpreter JS SDK ( npm install ./e2b-code-interpreter-2.8.1-devin-1790937617-pyqwest-native-balancing.0.tgzDesktop JS SDK ( npm install ./e2b-desktop-2.4.1-devin-1790937617-pyqwest-native-balancing.0.tgzPython SDK ( pip install ./e2b-2.52.0+devin.1790937617.pyqwest.native.balancing-py3-none-any.whlCode Interpreter Python SDK ( pip install ./e2b_code_interpreter-2.10.1+devin.1790937617.pyqwest.native.balancing-py3-none-any.whlDesktop Python SDK ( pip install ./e2b_desktop-2.6.0+devin.1790937617.pyqwest.native.balancing-py3-none-any.whl |
Summary
curioswitch/pyqwest#246 adds client-side load balancing to pyqwest's pool: it spreads an origin's HTTP/2 streams over connections by free stream capacity (from the server's
SETTINGS_MAX_CONCURRENT_STREAMS), dials another connection only once every existing one is full, and caps connections per resolved address viamax_connections_per_address. That is what our Python-sideConnectionBalancer/BalancingTransportdid by fanning out over multiple pyqwest transports, so this PR drops them and uses one native transport.E2B_MAX_CONNECTIONS(default200) now maps tomax_connections_per_address. Past the cap, a request waits for a stream on an existing connection (previously: piled onto the least-loaded one, same effect).E2B_STREAMS_PER_CONNECTIONis removed — the per-connection limit now comes from the server (envd edge advertises 100).ConnectionBalancer,PooledConnection,request_origin,BalancingTransport,_TrackedContent; response-lifetime slot accounting is now handled by pyqwest holding the hyper-util connection lease in response extensions until the body completes/closes.test_envd_stream_capacity.pyrewritten to assert the native pool's behavior against the local HTTP/2 frame server (waves of 80 streams at a 100-stream limit → 1, 2, 3 connections, freed streams reused; at a cap of 2 connections × 10 streams the 21st request waits until a stream closes), sync and async. Balancer unit tests removed.Unreleased pyqwest — do not release until fixed
pyqwest with #246 is not on PyPI yet, so
packages/python-sdk/pyproject.tomlpins it via a[tool.uv.sources]git source at the merge commitc4aae51(version0.11.0there) and the floor is bumped topyqwest>=0.11.0,<0.12. Thecode-interpreter-pythonanddesktop-pythonlockfiles are relocked because they pulle2bfrom the workspace path and inherit that source.tool.uv.sourcesis not included in published metadata, so before merging/releasing: drop the source block, set the floor to the actual pyqwest release, anduv lockall three packages. Until then,uv syncbuilds pyqwest from source (needs a Rust toolchain; ~1.5 min). pyqwest#246 also builds against[patch.crates-io]forks ofh2/hyper/hyper-util— worth confirming those land upstream (or that pyqwest ships wheels built from them) before relying on it.Link to Devin session: https://app.devin.ai/sessions/81af1a093fda4f22a89e3c1e4d78047c
Open in Devin Desktop: https://app.devin.ai/desktop/session/81af1a093fda4f22a89e3c1e4d78047c?variant=devin
Requested by: @mishushakov