Conversation
jonpspri
requested review from
Lang-Akshay,
brian-hussey,
crivetimihai,
ja8zyjits and
msureshkumar88
as code owners
June 29, 2026 21:00
jonpspri
force-pushed
the
remove-anyio-monkey-patch
branch
2 times, most recently
from
June 29, 2026 21:18
95d7157 to
b83df3b
Compare
jonpspri
force-pushed
the
remove-anyio-monkey-patch
branch
3 times, most recently
from
July 24, 2026 15:38
80dd80c to
7912de9
Compare
jonpspri
force-pushed
the
remove-anyio-monkey-patch
branch
from
September 1, 2026 09:35
7912de9 to
9ae7097
Compare
jonpspri
force-pushed
the
remove-anyio-monkey-patch
branch
from
September 14, 2026 10:35
9ae7097 to
72a04b2
Compare
Remove the experimental ANYIO_CANCEL_DELIVERY_PATCH_ENABLED feature that was used to mitigate CPU spin loops in anyio's _deliver_cancellation. Changes: - Remove monkey-patch implementation from sse_transport.py - Remove config settings (anyio_cancel_delivery_patch_enabled, anyio_cancel_delivery_max_iterations) - Remove related test functions - Update docker-compose files to remove Layer 3 environment variables - Update Helm chart values and schema - Update documentation to remove Layer 3 section and renumber layers The SSE connection protection (Layer 1) and cleanup timeouts (Layer 2) remain in place as the primary mitigation strategy. Signed-off-by: Jonathan Springer <jps@s390x.com>
Signed-off-by: Jonathan Springer <jps@s390x.com>
jonpspri
force-pushed
the
remove-anyio-monkey-patch
branch
from
September 14, 2026 11:04
72a04b2 to
33db76f
Compare
- Pin anyio>=4.15.0 (upstream _deliver_cancellation CPU spin fix, anyio#695/#1111); uv.lock now carries only the anyio 4.14.2 -> 4.15.0 bump - Remove dangling SSE_TASK_GROUP_CLEANUP_TIMEOUT, MCP_SESSION_POOL_CLEANUP_TIMEOUT, and ANYIO_CANCEL_DELIVERY_* references from docker-compose.yml, charts, and .env.example (Settings extra=ignore made them silent no-ops) - Rework cpu-spin-loop-mitigation.md and configuration.md: containment layer removed, layers renumbered, status reflects the shipped upstream fix; drop dead knob row from tuning.md - Update stale EventSourceResponse comment in translate.py and explorer.html node metadata; drop unrelated .gitignore entry Signed-off-by: Jonathan Springer <jps@s390x.com>
jonpspri
force-pushed
the
remove-anyio-monkey-patch
branch
from
September 14, 2026 11:09
33db76f to
0e9416d
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Remove the experimental
ANYIO_CANCEL_DELIVERY_PATCH_ENABLEDmonkey-patch (former Layer 3) and retire the now-obsolete SSE containment workaround for the CPU spin loop in anyio's_deliver_cancellation.The upstream root cause was fixed in anyio 4.15.0 ("Fixed unnecessary CPU spin when delivering cancellation from
CancelScopeon asyncio under certain conditions", anyio#695/#1111). This PR pinsanyio>=4.15.0inpyproject.tomlso the fix is guaranteed on every install path — that pin is what makes the removal safe, since the patch actually breaks if enabled against fixed anyio versions.Changes
Code Changes
EventSourceResponse.__call__cancel-deadline override (the SSE half of the former Layer 2 containment — its only consumer was the removed override). The class keeps the compression no-op and inherits sse-starlette's stock__call__.anyio_cancel_delivery_patch_enabled,anyio_cancel_delivery_max_iterations, andsse_task_group_cleanup_timeout.EventSourceResponseimport.Configuration Changes
anyio>=4.15.0floor; the lock carries only the anyio 4.14.2 → 4.15.0 bump.SSE_TASK_GROUP_CLEANUP_TIMEOUT,MCP_SESSION_POOL_CLEANUP_TIMEOUT(already a silent no-op since the pool-config removal in [BUG]: Problem with session management for stateful MCP Servers #4205), and theANYIO_CANCEL_DELIVERY_*entries.Documentation Changes
MCP_SESSION_POOL_CLEANUP_TIMEOUTrow.Rationale
anyio 4.15.0 fixes the
_deliver_cancellationspin loop upstream, making the experimental monkey-patch (which breaks if enabled against the fix) and the SSE cancel-deadline override unnecessary. Remaining mitigations: dead-client detection (SSE_SEND_TIMEOUT,SSE_RAPID_YIELD_*) and worker recycling (GUNICORN_MAX_REQUESTS); cleanup waits stay bounded via fixed 5-second windows in the session-pool and streamable-HTTP shutdown paths.Testing
make test: 23256 passed, 906 skipped, 2 xfailedmake ruff interrogate pylint: pass (interrogate 100%, pylint 10.00/10)make coverage diff-cover: 98% total, no uncovered diff linesmake docker-nuke docker-prod-rust testing-up RUST_MCP_MODE=: gateway stack upmake test-mcp-protocol-e2e test-mcp-rbac: pass (40 RBAC/transport tests)make detect-secrets-scan: cleanmake lint lint-valuespassCloses #6285 — remove anyio monkey-patch feature (chore/test-cleanup epic #5825).