]> git.pld-linux.org Git - projects/pld-builder.new.git/blame - PLD_Builder/lock.py
Switch to https for client/request handler server and between builders communication...
[projects/pld-builder.new.git] / PLD_Builder / lock.py
CommitLineData
dfff8bd5
MM
1# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
2
57b6e61d
MM
3import fcntl
4
5import path
6
9a8908ac
MM
7locks_list = []
8
4d9b6f71 9def lock(n, non_block = 0):
9be34149 10 f = open(path.lock_dir + '/' + n, "a")
dfff8bd5
MM
11 # blah, otherwise it gets garbage collected and doesn't work
12 locks_list.append(f)
13 if non_block:
14 try:
15 fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
16 except:
17 f.close()
18 return None
19 else:
20 fcntl.flock(f, fcntl.LOCK_EX)
21 return f
This page took 0.216979 seconds and 4 git commands to generate.