Éric Larivière <ericlarivi...@hotmail.com> added the comment:

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)

----------
nosy: +elarivie
versions:  -Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue8800>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to