skip to navigation
skip to content

lockfile 0.8

Platform-independent file locking module

The lockfile module exports a FileLock class which provides a simple API for locking files. Unlike the Windows msvcrt.locking function, the Unix fcntl.flock, fcntl.lockf and the deprecated posixfile module, the API is identical across both Unix (including Linux and Mac) and Windows platforms. The lock mechanism relies on the atomic nature of the link (on Unix) and mkdir (on Windows) system calls.

Version 0.8 works around a bug in the threading module.

Log in to rate this package.

Package rating (2 votes): 4.5
  • 4 points: 1 vote
  • 5 points: 1 vote

Ratings range from 0 to 5 (best).

Package Comments:
  • Divius (2009-10-18, 5 points):
    It's cool but LinkFileLock doesn't clean unique_name on break_lock().
    Add the following lines to LinkFileLock.break_lock:
    if os.path.exists(self.unique_name):
    os.unlink(self.unique_name)
  • bialix (2009-12-28, 4 points):
    Your library missed the feature to "break" the lock if the process which created the lock was killed and did not removed the lock.