gh-140947: fix contextvars handling for server tasks in asyncio by kumaraditya303 · Pull Request #141158 · python/cpython
Bot
mentioned this pull request
CuriousLearner added a commit to CuriousLearner/cpython that referenced this pull request
Kludex added a commit to Kludex/uvicorn that referenced this pull request
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.
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