I needed a reader-writer lock to use in the second readers-writers problem with python threads. In this problem, many readers can simultaneously access a share, and a writer has an exclusive access to this share. Additionally, the following constraints should be met: 1) no reader should be kept waiting if the share is currently opened for reading unless a writer is also waiting for the share, 2) no writer should be kept waiting for the share longer than absolutely necessary.
Surprisingly, I wasn’t able to find an implementation of such a synchronization object that met some basic common-sense requirements: 1) simple, clear implementation, 2) tested with some basic unit tests. So, I wrote my own version — it is placed here: http://code.activestate.com/recipes/577803-reader-writer-lock-with-priority-for-writers .