xlocal
execution locals: killing global state (including thread locals)
What it is and what it does
xlocal implements execution-local storage—a restricted variant of thread-local storage where attribute bindings are scoped to a context-managed code block and all functions it calls, rather than persisting globally or thread-wide. Attributes set via a with-statement are visible to all code invoked within that block, including nested function calls, but are automatically cleaned up when the block exits and do not leak to other threads or greenlets.
The package is designed for frameworks and libraries that invoke handler or plugin code and want to pass execution-specific state without using globals or thread locals. It prevents called code from rebinding state of its caller and ensures clean lifecycle management. However, the package has been abandoned since 2012-11-16 and is not actively maintained.
Use it for:
- Pass request-specific context to handler functions spawned in threads or greenlets without using globals.
- Implement per-execution state in web frameworks or plugin systems where multiple concurrent executions need isolated bindings.
- Prevent state leakage when invoking user code that should not modify the caller's execution context.
- Manage thread-local or greenlet-local state with explicit lifecycle control via context managers.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides execution-local storage that scopes attribute bindings to a code block and its callees, preventing state leakage across threads or greenlets.
No. The package is abandoned (last release 2012-11-16, no maintenance since), has unclear licensing, high install friction (zip-only distribution), and unspecified Python version support. Modern alternatives provide similar functionality with active maintenance. Use only if maintaining legacy code already depending on it.
Install
xlocal on PyPI
pip
pip install xlocaluv
uv add xlocalpoetry
poetry add xlocalInstalling xlocal
Before you install
High install friction: distributed as a zip file rather than a wheel or sdist. Package is abandoned—last release was 2012-11-16 with no commits or maintenance activity since. Not suitable for new projects.
License in practice
License is marked UNKNOWN with no SPDX identifier; actual licensing terms are unclear. Verify the LICENSE file in the source before using in commercial or copyleft-sensitive contexts.
Quickstart
from xlocal import xlocal
xcurrent = xlocal()
with xcurrent(x=1):
print(xcurrent.x) # prints 1
# Outside the context, xcurrent.x raises AttributeError
Python version support is unspecified; package was last released in 2012 and may not work on modern Python versions.
Verify before relying
- Whether xlocal works on current Python versions or only on Python 2.x.
- Current compatibility with modern threading or async/await patterns.
- Whether the zip distribution includes all necessary files or if setup.py is present.
Package facts
| License | UNKNOWN (unclear) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | abandoned — 5,019 days since the last release |
| First released | |
| Downloads | 132,453/month — #11,552 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: xlocal-0.5.zip
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI 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
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
psutil-home-assistantWraps psutil to allow multiple independent…
permissive · top 15,000 on PyPI
Flask-ThreadsProvides thread and thread pool helpers that…
unclear · top 5,000 on PyPI
greenletGreenlet provides lightweight coroutines for…
permissive · top 100 on PyPI
proxy_toolsProvides a lazy-evaluation proxy object that…
permissive · top 5,000 on PyPI
threadedProvides decorators to wrap functions for…
permissive · top 15,000 on PyPI
opentelemetry-instrumentation-threadingEnsures OpenTelemetry context is propagated…
permissive · top 1,000 on PyPI
kthreadKThread provides a way to forcefully terminate…
permissive · top 15,000 on PyPI
stopitProvides context managers and decorators to…
permissive · top 15,000 on PyPI
pytest-threadleakA pytest plugin that detects when tests leak…
permissive · top 15,000 on PyPI
opencensus-contextProvides in-process context propagation for…
permissive · top 1,000 on PyPI