Skip to content

Commit 277795e

Browse files
committed
function_storage_cf_do: switch from http.client to httpx.Client
The previous implementation shared a single http.client.HTTPConnection across threads, whose state machine (IDLE -> REQ_STARTED -> REQ_SENT) corrupts under concurrent use. Symptom from the HTTP fixture worker running concurrent producer turns: ResponseNotReady: Idle raised from getresponse() because another thread reset the conn between request() and getresponse(). httpx.Client is thread-safe by construction — its connection pool serialises per-connection access — so the threading.local workaround disappears, along with manual request/getresponse/read/json.loads plumbing. Connect-level retries are delegated to HTTPTransport; status- and transport-level retries (5xx, RemoteProtocolError, non-JSON response bodies) stay in _post for control over the backoff policy. httpx is declared as a direct dependency now that it's load-bearing in core code (it was already pulled in transitively for vgi/client/). Tests rewritten on top of httpx.MockTransport. New regression coverage: concurrent-thread safety, 5xx retry, retry exhaustion, transport-error retry, non-JSON response retry, 4xx no-retry, close() releases the client.
1 parent 5e38a2e commit 277795e

4 files changed

Lines changed: 334 additions & 201 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ dependencies = [
1111
"platformdirs",
1212
"vgi-rpc @ file:///Users/rusty/Development/vgi-rpc",
1313
"duckdb>=1.5.0",
14+
"httpx>=0.24",
1415
]
1516

1617
[project.optional-dependencies]

0 commit comments

Comments
 (0)