]> git.pld-linux.org Git - projects/pld-builder.new.git/blob - PLD_Builder/lock.py
- lots of fixes
[projects/pld-builder.new.git] / PLD_Builder / lock.py
1 import fcntl
2
3 import path
4
5 locks_list = []
6
7 def lock(n, non_block = 0):
8   f = open(path.lock_dir + n, "a")
9   # blah, otherwise it gets garbage collected and doesn't work
10   locks_list.append(f)
11   if non_block:
12     try:
13       fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
14     except:
15       f.close()
16       return None
17   else:
18     fcntl.flock(f, fcntl.LOCK_EX)
19   return f
This page took 0.031682 seconds and 4 git commands to generate.