Update vendored httpx-ws to upstream v0.9.0
Merged
KL
3mo ago+894+894+012345678901234567890123456789-345-345-012345678901234567890123456789
Closes the gap reported in #1066: the vendoring in #1042 accidentally used frankie567/httpx-ws@6bc568b (v0.6.2 era, October 2024). This ports every upstream change from there to the current tip, frankie567/httpx-ws@0341891 (v0.9.0 + 6 commits) - 80 commits, of which 38 touch library or test code; the rest are upstream CI/docs/tooling.
What comes in
- Write lock serializing stream writes (httpx-ws#29)
- Async session rebuilt on
anyio.AsyncContextManagerMixin, fixing the asyncio hang on exit after cancellation and cancel scope corruption (httpx-ws#108);anyio>=4.10is now required ASGIWebSocketTransportrewritten on a task group and anyio streams instead of a blocking portal andqueue.Queue- WebSocket Denial Response ASGI extension support
- Configurable
initial_receive_timeoutwith a clear error when the server never callsaccept() TimeoutErrorinstead ofqueue.Emptyon sync receive timeout (docs updated)- Proper end-of-stream handling and keepalive ping exit when the connection is closing
- Class-based
WebSocketClient/AsyncWebSocketClientwithsession_classsupport, exported fromhttpx2.websockets
Deliberate deviations from upstream
- httpx2 adaptations preserved: relative imports, lazy
httpcore2imports, explicit handshake parameters instead of**kwargs,Client.websocket()as the public entry point (connect_ws/aconnect_wsstay unexported) session_classlives only on the client classes, not onconnect_ws/aconnect_ws: mypy cannot infer the PEP 696 TypeVar default through thecontextmanagerdecorator- Two fixes upstream does not have (worth PRing back):
acloseis registered before the initial receive so a never-accepting app does not leak memory object streams, and the double-__aenter__guard is covered by a test
Verification
- 164 websocket tests pass on asyncio and trio, 3 consecutive full runs; whole httpx2 suite: 1634 passed
- 100% coverage on all
websockets/files; ruff format, ruff check, mypy strict, unasync all clean - Independently reviewed by Codex against the full upstream commit range: all 38 code commits verified present, no porting bugs found
AI Disclaimer
This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.