Commit 277795e
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
0 commit comments