Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def check_posix_lock(filename):
- ''' check if POSIX lock (fcntl/lockf) is held on filename '''
- lockfile = None
- try:
- lockfile = open(filename, 'w')
- fcntl.lockf(lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
- except BlockingIOError:
- return True
- except:
- pass
- finally:
- if lockfile:
- lockfile.close()
- return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement