--- id: readerwriterlock version: "1.0.9" license: MIT license_treatment: permissive maintenance: abandoned --- # readerwriterlock — A python implementation of the three Reader-Writer problems. License: permissive · Maintenance: abandoned · Downloads: 2.7M/mo ## What it is and what it does readerwriterlock is a pure-Python implementation of the three classical reader-writer synchronization problems—a concurrency pattern where multiple readers can hold a lock simultaneously, but writers require exclusive access. The package provides six lock classes: three prioritize readers, writers, or fairness respectively, and three downgradable variants that allow atomically converting a write lock to a read lock (with a documented ~20% performance cost). All classes conform to Python's standard threading.Lock interface, including support for timeouts and context managers. You instantiate a lock class, then call gen_rlock() or gen_wlock() to create reader or writer lock objects that you acquire and release in your code. The choice of class determines scheduling behavior: reader-priority favors read throughput, writer-priority prevents writer starvation, and fair-priority balances both. The package depends only on typing-extensions and has no system-level dependencies. Use it for: - Protect a shared cache or in-memory data structure where reads vastly outnumber writes and you want many concurrent readers. - Implement a fair lock for a resource where both readers and writers must be served without starvation, such as a shared log or configuration store. - Build a write-heavy system where writer priority prevents reader threads from blocking critical updates indefinitely. - Use lock downgrading when a thread acquires write access to check-then-update a value, then only needs read access afterward without releasing and re-acquiring. - Add timeout-based lock acquisition to detect and handle deadlock scenarios in multi-threaded applications. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides reader-writer lock implementations for Python that solve the three classical reader-writer synchronization problems with configurable priority schemes (reader, writer, or fair) and optional lock downgrading. Yes, if you need a reader-writer lock and are comfortable with an abandoned package. The implementation is marked Production/Stable with no known vulnerabilities and has 104 GitHub stars, suggesting stability. Reader-writer locks are a well-understood pattern unlikely to require frequent updates. However, verify compatibility with your Python version and consider whether the lack of maintenance is acceptable for your use case. ## Install pip install readerwriterlock uv add readerwriterlock poetry add readerwriterlock ## Installing readerwriterlock Before you install: Low install friction with a single pure-Python dependency. However, the package is abandoned—last release was 2021-09-06 with no recent commits. Use only if you need a stable, unchanging implementation and can maintain it yourself if issues arise. License in practice: MIT license (permissive) means you can use, modify, and distribute this package freely in commercial or private projects with minimal restrictions, provided you include the license notice. Quickstart: from readerwriterlock import rwlock a = rwlock.RWLockFairD() with a.gen_rlock(): # read operation pass with a.gen_wlock(): # write operation pass Verify before relying: - Whether the implementation has been tested against Python versions beyond 3.9 or if there are known compatibility issues with newer releases. - Real-world performance characteristics and scalability limits compared to alternatives or standard library threading primitives. - Whether the ~20% performance cost of downgradable locks applies uniformly across all three priority schemes. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: abandoned - Downloads: 2.7M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags reader writer lock python, rwlock synchronization, thread lock priority, concurrent read write access, fair lock implementation, downgrade write to read lock, reader priority lock, concurrency, threading, synchronization [View on SkillFed](https://skillfed.io/packages/readerwriterlock) · [View on PyPI](https://pypi.org/project/readerwriterlock/)