aiologic
GIL-powered* locking library for Python
What it is and what it does
aiologic is a synchronization library that solves a specific problem: coordinating work across Python's different concurrency models. Standard asyncio.Lock fails when tasks from different event loops try to acquire it, and threading.Lock can deadlock in similar scenarios. aiologic provides drop-in replacements—Lock, Event, Semaphore, Barrier, Condition, and Queue primitives—that work correctly whether you're coordinating async tasks within one loop, async tasks across multiple event loops in different threads, or mixing async and sync code.
The library supports asyncio, trio, curio, anyio, gevent, eventlet, and threading. It's built on atomic operations and respects Python's GIL, making it performant on PyPy and compatible with free-threaded CPython 3.13+. The implementation includes fairness guarantees where possible and aims for lock-free designs with minimal context switches. It's in alpha, actively maintained, and already in use by some projects.
Use it for:
- Coordinate async tasks running in separate event loops across multiple threads without deadlock or RuntimeError.
- Protect shared state when mixing async code (asyncio/trio) with synchronous code in the same application.
- Build thread-safe async queues and barriers that work across different async frameworks (asyncio, trio, curio, anyio).
- Implement fair, cancellation-aware locking for complex async workflows with timeouts and checkpoints.
- Migrate from threading.Lock to an async-aware primitive without rewriting synchronization logic.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
aiologic provides thread-aware and async-aware locking and synchronization primitives that work across asyncio, trio, curio, anyio, gevent, eventlet, and threading—enabling safe coordination between async tasks in different event loops and between async and sync code.
Yes, if you need to coordinate async tasks across multiple event loops or mix async and sync code—a genuine gap in the standard library. No, if you work only within a single asyncio event loop or use only threading; standard library primitives are simpler and more stable. Yes-with-conditions if you're comfortable with alpha-status software and a single-maintainer project; the library is already in use and carefully designed, but API and behavior may change.
Install
aiologic on PyPI
pip
pip install aiologicuv
uv add aiologicpoetry
poetry add aiologicInstalling aiologic
Before you install
Low install friction with only three runtime dependencies (sniffio, typing-extensions, wrapt). Actively maintained as of 2026-06-27 with recent activity. Project is in alpha status and developed by a single maintainer in spare time, so stability is not guaranteed despite careful theoretical analysis claimed by the author.
License in practice
Permissive licensing: source code under ISC, tests under 0BSD, documentation under CC-BY-4.0, and configuration under CC0-1.0. No restrictions on commercial use or modification of the library itself.
Quickstart
import asyncio
from threading import Thread
import aiologic
lock = aiologic.Lock()
async def func():
async with lock:
await asyncio.sleep(1)
Thread(target=asyncio.run, args=[func()]).start()
Requires Python 3.8 or later. Works on CPython and PyPy; Nuitka support is experimental.
Verify before relying
- Performance characteristics and fairness guarantees compared to standard library alternatives in various concurrency scenarios.
- Stability and API maturity given alpha development status and single-maintainer maintenance model.
- Real-world production usage patterns beyond the one discussion example mentioned in the project status.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — sniffio, typing-extensions, wrapt |
| Maintenance | actively maintained — 48 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,253,484/month — #2,684 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: aiologic-0.17.1-py3-none-any.whl
Keywords: anyio, async, async-await, asyncio, concurrency, eventlet, gevent, greenlet, library, locking, mypy, python, synchronization, thread-safety, threading, trio
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
aiorwlockProvides read-write locks for asyncio programs,…
permissive · top 5,000 on PyPI
culsansProvides a dual-interface queue (sync and…
permissive · top 5,000 on PyPI
anyioAnyIO provides a unified asynchronous API that…
permissive · top 100 on PyPI
fifolockFifolock provides a low-level building block…
permissive · top 15,000 on PyPI
asyncguiAsyncGui provides structured concurrency…
permissive · top 15,000 on PyPI
aiotoolsaiotools provides idiomatic asyncio utilities…
permissive · top 15,000 on PyPI
fastenersProvides cross-platform locks for synchronizing…
permissive · top 5,000 on PyPI
pytest-aioA pytest plugin that automatically runs async…
permissive · top 15,000 on PyPI
atomosAtomos provides thread-safe atomic primitives…
permissive · top 15,000 on PyPI
janusProvides a thread-safe queue with both…
permissive · top 5,000 on PyPI