oslo.context
Oslo Context library
What it is and what it does
oslo.context is a small library from the OpenStack project that helps you store and retrieve request-scoped metadata—such as request IDs, user identifiers, and project names—in a way that's accessible throughout your application without passing context as a function parameter. It's typically used in WSGI applications to populate context in the middleware layer, then accessed by logging and other modules downstream.
The library uses thread-local (or async-context-aware) storage to keep request data isolated between concurrent requests. It's designed as a utility for larger OpenStack-based systems but can be used standalone in any Python application that needs to track request metadata across function call boundaries.
Use it for:
- Store and retrieve request IDs in WSGI middleware to correlate logs across service calls.
- Maintain user and project identifiers in context for access control checks in business logic.
- Populate logging formatters with request metadata without threading context through every function.
- Track request-scoped data in OpenStack services and compatible cloud applications.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
oslo.context provides utilities to store and access request context information—such as request IDs and user details—that can be shared across a WSGI application and its logging pipeline.
Yes, if you're building a WSGI application that needs to propagate request metadata (IDs, user info) across your codebase without explicit parameter passing. Low install friction, active maintenance, no known vulnerabilities, and permissive licensing make it a safe choice. Not necessary for simple scripts or applications that don't need request-scoped context.
Install
oslo-context on PyPI
pip
pip install oslo-contextuv
uv add oslo-contextpoetry
poetry add oslo-contextInstalling oslo.context
Before you install
Low friction: pure Python wheel, only two lightweight runtime dependencies (pbr and typing-extensions). Active maintenance with a release 35 days ago. Requires Python 3.11 or later.
License in practice
Apache License 2.0 (permissive): you can use, modify, and distribute this package freely in commercial and private projects, provided you include the license notice.
Quickstart
pip install oslo.context
from oslo_context import context
ctx = context.RequestContext(user='alice', project='myproject')
context.set_ctx(ctx)
request_id = context.get_current().request_id
Requires Python 3.11 or later.
Verify before relying
- Whether oslo.context integrates automatically with WSGI frameworks or requires manual middleware setup.
- What specific request metadata fields are available beyond user and project identifiers.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — pbr, typing-extensions |
| Maintenance | actively maintained — 35 days since the last release |
| First released | |
| Downloads | 988,879/month — #4,568 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: oslo_context-6.5.0-py3-none-any.whl
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
oslo.middlewareoslo.middleware provides WSGI middleware…
permissive · top 15,000 on PyPI
oslo.utilsoslo.utils provides common utility functions…
permissive · top 5,000 on PyPI
oslo.serviceoslo.service provides a framework for building…
permissive · top 15,000 on PyPI
oslo.logoslo.log provides standardized logging…
permissive · top 5,000 on PyPI
oslo.dboslo.db provides database connectivity and ORM…
permissive · top 15,000 on PyPI
oslo.policyoslo.policy enforces role-based access control…
permissive · top 15,000 on PyPI
oslo.configParses command-line arguments and .ini-style…
permissive · top 5,000 on PyPI
oslo.vmwareoslo.vmware provides a library for common…
permissive · top 15,000 on PyPI
oslo.i18noslo.i18n provides utilities for handling…
permissive · top 5,000 on PyPI
microversion-parseParses and validates OpenStack microversion…
permissive · top 15,000 on PyPI