system wide mutex

Roy Smith roy at panix.com
Sun Feb 9 15:45:52 CET 2014


In article <mailman.6578.1391943647.18130.python-list at python.org>,
 Skip Montanaro <skip at pobox.com> wrote:

> > Which one is most recommended to use for mutex alike locking to
> > achieve atomic access to single resource:
> >
> > - fcntl.lockf
> > - os.open() with O_SHLOCK and O_EXLOCK
> > - https://pypi.python.org/pypi/lockfile/0.9.1
> > - https://pypi.python.org/pypi/zc.lockfile/1.1.0
> > - any other ?
> 
> As the author of lockfile, I can tell you it only implements advisory
> locking. All programs needing to access the locked resources must
> cooperate.

This is true of all mutexes, no?

We needed a mutex that worked across multiple machines, so we ended up 
implementing a mutex in memcache.  We based ours on 
http://tinyurl.com/lybx2kl, but if you google for "memcache mutex 
python", you'll find a number of implementations.



More information about the Python-list mailing list