harlowja / fasteners

A python package that provides useful locks.
Apache License 2.0
246 stars 45 forks source link

How to use this library? #28

Closed catb0t closed 1 year ago

catb0t commented 7 years ago

I was looking into the tests folder to try to find a code example I could work from, but it left me as baffled as the documentation.

Excerpted from class ReadWriteLockTest in test_lock.py:

def test_no_double_writers(self):
        lock = fasteners.ReaderWriterLock()   # a lock on what exactly? no filename is given
        watch = _utils.StopWatch(duration=5)
        watch.start()
        dups = collections.deque()
        active = collections.deque()

        def acquire_check(me):
            with lock.write_lock():    # what does this with statement lock?

Neither in the documentation nor in the testing code is it very clear, how to use this ReaderWriterLock to lock access to a resource? A filename, nor any sort of context is ever given to these functions.

harlowja commented 6 years ago

A reader-writer lock is https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock

philippludwig commented 3 years ago

Same here. Nice that there is an article available about the theory behind it, but that still does not explain how this library is intended to be used.

psarka commented 3 years ago

I'll note that the README was rewritten with this question in mind, but I will keep this issue open until the documentation is improved as well.

psarka commented 1 year ago

Documentation is now pretty good :tada: