aiocontextvars
Asyncio support for PEP-567 contextvars backport.
Decision gist · record as of 2026-08-14
No, unless you are maintaining legacy code on Python 3.5 or 3.6 that requires contextvars asyncio support. The package is abandoned (last release 2019, last commit 2022) and unnecessary on Python 3.7+. Modern Python versions have built-in contextvars with full asyncio support; use the standard library instead.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- On Python 3.5 and 3.6, must import aiocontextvars before creating event loops or tasks; custom event loop implementations (e.g., uvloop.new_event_loop) will not be patched and won't behave correctly.
- Low install friction with a single pure-Python dependency.
- However, the package is abandoned—last release was in 2019 and last commit in 2022.
License · maintenance · safety
BSD license (permissive) — BSD license is permissive and imposes no significant restrictions on use or redistribution.
last release 2019-04-08 (2685 days) · last repo commit 2022-12-26 · 56 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 446,231 downloads/mo, #6,613 on PyPI
Alternatives
Verify before relying
pip install aiocontextvars
import aiocontextvars
import asyncio
from contextvars import ContextVar
var = ContextVar('var')
var.set('value')
async def main():
print(var.get())
asyncio.run(main())- Whether the package still works reliably with modern asyncio implementations given its age and abandonment status.
- Whether the contextvars asyncio backport issue mentioned in the description has since been resolved in the upstream contextvars package.
What it is and what it does
aiocontextvars patches the contextvars backport library to add asyncio support for Python 3.5 and 3.6, allowing context variables to be properly inherited and maintained across async task boundaries. On Python 3.7+, it is simply a pass-through to the built-in contextvars module, which already has full asyncio integration.
The package works by monkey-patching asyncio's event loop and task creation to attach and propagate copied contexts. It requires importing the module before creating any event loops or tasks to ensure the patches are applied. On older Python versions, it provides a workaround for the lack of native context parameter support in call_soon() and Task creation, though the implementation differs from Python 3.7's native approach.
Use it for
- Maintaining request-scoped context (e.g., user ID, request ID) across async task chains on Python 3.5–3.6.
- Migrating legacy asyncio code from Python 3.5–3.6 that relies on context variable inheritance to Python 3.7+.
- Ensuring context isolation between concurrent tasks in older Python versions before native contextvars asyncio support existed.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
No, unless you are maintaining legacy code on Python 3.5 or 3.6 that requires contextvars asyncio support.
The package is abandoned (last release 2019, last commit 2022) and unnecessary on Python 3.7+. Modern Python versions have built-in contextvars with full asyncio support; use the standard library instead.
Install
aiocontextvars on PyPI
Before you install
Low install friction with a single pure-Python dependency. However, the package is abandoned—last release was in 2019 and last commit in 2022. On Python 3.7+, it is purely a delegate to the built-in contextvars module, making it unnecessary for modern codebases.
On Python 3.5 and 3.6, must import aiocontextvars before creating event loops or tasks; custom event loop implementations (e.g., uvloop.new_event_loop) will not be patched and won't behave correctly.
License in practice
BSD license is permissive and imposes no significant restrictions on use or redistribution.
Quickstart
pip install aiocontextvars
import aiocontextvars
import asyncio
from contextvars import ContextVar
var = ContextVar('var')
var.set('value')
async def main():
print(var.get())
asyncio.run(main())
Verify before relying
- Whether the package still works reliably with modern asyncio implementations given its age and abandonment status.
- Whether the contextvars asyncio backport issue mentioned in the description has since been resolved in the upstream contextvars package.
Package facts
| License | BSD license permissive |
| Python support | Supports the current Python release >=3.5 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagecontextvars |
| Maintenance | Abandoned 2,685 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 446,231 / month, #6,613 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseNatural Language :: EnglishProgramming Language :: Python :: 3Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6 |
Evidence: aiocontextvars-0.2.2-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “contextvars asyncio support”
- aiocontextvarsProvides asyncio support for the contextvars backport library on…
- opencensus-contextProvides in-process context propagation for OpenCensus, automatically…
- types-contextvarsProvides type stubs for Python's contextvars module, enabling static…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also contextvars · types-contextvars · opencensus-context · backports.asyncio.runner · asyncio · taskgroup · nest-asyncio · aiomcache · nest-asyncio2 · backports_abc