--- id: aiorwlock version: "1.5.1" license: Apache-2.0 license_treatment: permissive maintenance: active --- # aiorwlock — Read write lock for asyncio. License: permissive · Maintenance: active · Downloads: 1.3M/mo ## What it is and what it does aiorwlock implements a read-write lock primitive for asyncio-based Python programs. It maintains separate locks for read and write operations: the read lock can be held by multiple concurrent reader tasks simultaneously, while the write lock is exclusive and blocks all other readers and writers. This design improves performance when data is read frequently but modified infrequently, since readers don't block each other. The package is a direct port of a CPython patch and has been in production use since 2014. It supports a "fast path" mode that skips context switches when you're confident your locked code contains await statements, trading safety for minor performance gains. The default safe mode ensures fairness by allowing waiting tasks to acquire the lock even if the current holder doesn't yield control. Use it for: - Cache or configuration store that is read frequently but updated rarely - Shared data structure in an async web service where reads vastly outnumber writes - Coordinating access to a resource pool where multiple consumers read status but few modify state - Implementing reader-writer patterns in async database connection managers - Protecting mutable state in async event handlers where contention is primarily read-heavy ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides read-write locks for asyncio programs, allowing multiple concurrent readers or a single exclusive writer to synchronize access to shared data. Yes. aiorwlock is a mature, actively maintained library with zero known vulnerabilities, low install friction, and permissive licensing. Install it if you have asyncio code where read-write contention patterns would benefit from allowing concurrent readers; otherwise a simple asyncio.Lock is sufficient. ## Install pip install aiorwlock uv add aiorwlock poetry add aiorwlock ## Installing aiorwlock Before you install: Low install friction with no runtime dependencies. Actively maintained with recent commits and a stable release history since 2014; supports current Python versions (3.9 through 3.14). License in practice: Licensed under Apache 2.0 (permissive), allowing use in both open-source and proprietary projects with minimal restrictions. Quickstart: import asyncio import aiorwlock async def example(): rwlock = aiorwlock.RWLock() async with rwlock.reader_lock: print('reader holds lock') async with rwlock.writer_lock: print('writer holds lock') asyncio.run(example()) Requires Python 3.9 or later. The task that acquires a lock must also release it; acquiring in one task and releasing in another raises RuntimeError. Verify before relying: - Performance characteristics compared to simple mutual exclusion locks under various read/write ratios - Thread-safety guarantees or limitations when used across multiple event loops ## Package facts - License: Apache-2.0 (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 1.3M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags asyncio read write lock, concurrent reader writer lock, async rwlock, asyncio synchronization primitive, async mutual exclusion, reader writer synchronization, asyncio lock multiple readers, asyncio, concurrency, synchronization [View on SkillFed](https://skillfed.io/packages/aiorwlock) · [View on PyPI](https://pypi.org/project/aiorwlock/)