skillfed

oslo.context

Oslo Context library

oslo-context v6.5.0 988.9K downloads/30d#4,568 on PyPI
Permissive license Apache-2.0 Active released

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-context

uv

uv add oslo-context

poetry

poetry add oslo-context

Installing 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

Environment :: OpenStackIntended Audience :: Information TechnologyIntended Audience :: System AdministratorsOperating System :: POSIX :: LinuxProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonTyping :: Typed

Tags

request context managementwsgi context trackingrequest id propagationcontext-local storagelogging context helpersopenstack context librarythread-local request data
openstackwsgi-middlewarerequest-tracking

More Application Frameworks packages