This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author elarivie
Recipients Ofekmeister, Sebastian.Noack, asvetlov, christian.heimes, dan.oreilly, elarivie, jcea, jyasskin, kristjan.jonsson, mklauber, neologix, njs, pitrou, sbt, vrutsky
Date 2020-01-15.06:09:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1579068597.08.0.449173756103.issue8800@roundup.psfhosted.org>
In-reply-to
Content
Hi,

Sorry to wake up a 10 years old discussion


But I think that you might be interested in the following Python package that I created and maintain since few years now:

    https://pypi.org/project/readerwriterlock/


1- It implements the three type of reader writer lock:
  - Read Priority
  - Write Priority
  - Fair Priority

2- It matches the interface of python threading.Lock

  More specifically:
    def acquire(self, blocking: bool = True, timeout: float = -1) -> bool:
    def release(self) -> None:

As you can see it supports the 'blocking' and the 'timeout' parameters) and it uses the same methods name

3- It supports context manager (__enter__, __exit__)

4- It is also possible (currently not well documented) to provide a lock factory when initializing a new reader writer lock to specify the internal lock mechanism to use (by default it uses threading.Lock).

    def __init__(self, lock_factory: Callable[[], Lockable] = lambda: threading.Lock()) -> None:

This hidden feature allows to offer the possibility to implement your own lock mechanism (using port, file on disk, etc, ...) and the reader writer lock will internally use it (This open the door for multiprocessing locking)
History
Date User Action Args
2020-01-15 06:09:57elariviesetrecipients: + elarivie, jcea, pitrou, kristjan.jonsson, christian.heimes, jyasskin, njs, asvetlov, neologix, vrutsky, sbt, mklauber, Sebastian.Noack, dan.oreilly, Ofekmeister
2020-01-15 06:09:57elariviesetmessageid: <1579068597.08.0.449173756103.issue8800@roundup.psfhosted.org>
2020-01-15 06:09:57elarivielinkissue8800 messages
2020-01-15 06:09:56elariviecreate