Skip to content

Keep HTTP/2 uploads multiplexed while serializing shared h2 state - #2

Merged
Jacob-Met merged 2 commits into
masterfrom
fix/h2-thread-safe-multiplexing
Nov 16, 2026
Merged

Jacob-Met merged 2 commits into
masterfrom
fix/h2-thread-safe-multiplexing

Conversation

@Jacob-Met

Copy link
Copy Markdown
Owner

A shared HTTP/2 connection now serializes all in-memory h2 state changes without holding a lock over slow uploads, preventing duplicate stream IDs and HPACK corruption; this extends Priyankm23's original source commit 7d48dcc with safe cancellation before/after stream allocation and preserves Python >=3.8 developer dependencies. The deterministic 8-thread/400-request stress test is derived from upstream PR #1118, which stalls or fails in the in-flight upload scenario.

Current working source is 43c8d1a; 230 tests passed (6 pre-existing XPASS), 10/10 forced-race stress repetitions, unasync mirror/lint/type checks pass, and a built wheel passes 400 simultaneous HTTP/2 requests and a loopback server that allows GET during an ongoing POST upload. No upstream contribution was opened: both GitHub PAT and connector returned 403, and encode#1118 already exists.

Next fault: outbound flow-control credit can fall below zero on large bodies (encode#1082), which still needs a failing concurrent-window reproduction before any change. This PR merges into the maintained fork only; AI-assisted integration and tests were performed by GPT-6, with the original author's commit retained.

Priyankm23 and others added 2 commits November 16, 2026 06:31
Place the stream ID in the caller before awaiting socket writes, so cancellation releases active-stream capacity and removes allocated events. Clean up before-allocation errors, and preserve Python 3.8-compatible development requirements. Add deterministic concurrent stream-ID and cancellation regressions.
@Jacob-Met
Jacob-Met merged commit 8ed35e5 into master Nov 16, 2026
@Jacob-Met
Jacob-Met deleted the fix/h2-thread-safe-multiplexing branch November 16, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants