◐ Shell
clean mode source ↗

gh-140947: fix contextvars handling for server tasks in asyncio by kumaraditya303 · Pull Request #141158 · python/cpython

@kumaraditya303

@bedevere-app Bot mentioned this pull request

Nov 6, 2025

@kumaraditya303

CuriousLearner added a commit to CuriousLearner/cpython that referenced this pull request

Mar 22, 2026

Kludex added a commit to Kludex/uvicorn that referenced this pull request

Apr 21, 2026
Reintroduces the behavior from #2742 as an opt-in flag. When set, each
ASGI request runs in a fresh contextvars.Context, which works around
the asyncio context leak in python/cpython#140947
(expected to be fixed upstream for Python >=3.15 via python/cpython#141158).

Default is off so context set in the lifespan or by external
instrumentation (e.g. OpenTelemetry eBPF propagation) remains visible
to ASGI handlers.

ljfp pushed a commit to ljfp/cpython that referenced this pull request

Apr 25, 2026