title: Shared and exclusive named lock for python
body: <p>I need to synchronize python threads and processes (not necessary related with each other) with named lock (file lock for example). Preferably it should be readers-writer lock. I have tried fcntl.flock (it have both exclusive and shared lock acquisition) but it does not provide desired level of locking - <a href="https://stackoverflow.com/questions/3899435/does-pythons-fcntl-flock-function-provide-thread-level-locking-of-file-access">Does python&#39;s fcntl.flock function provide thread level locking of file access?</a></p>
  
  <p>My solution so far is to use <a href="http://packages.python.org/lockfile/lockfile.html" rel="nofollow noreferrer">lockfile</a> with memcached (or mmap'ed locked file). Lockfile will synchronize access and memcached will count readers/writers.</p>
  
  <p>Are there any better/faster solutions? Do you know any project which already solves this problem?</p>