Skip to content

Instantly share code, notes, and snippets.

View jmckib's full-sized avatar

Jeremy Velev jmckib

  • San Francisco, CA
View GitHub Profile
@jmckib
jmckib / README
Created January 26, 2011 02:08
python file lock using flock(2) system call
Tested on Mac OS X 10.6.6 and Ubuntu 10.10 with Python 2.6.6
To try it out, open up a python shell and type:
>>> from lock import FileLock
>>> lock = FileLock("my_lock", dir="/var/tmp")
>>> lock.acquire()
Leave the first shell open, and open another python shell and type the same thing:
>>> from lock import FileLock
>>> lock = FileLock("my_lock", dir="/var/tmp")