[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / lldb / packages / Python / lldbsuite / test / lock.py
blobe9970e135f933f4d226323984a24d82e6321bf01
1 """
2 Interprocess mutex based on file locks
3 """
5 import fcntl
8 class Lock:
10 def __init__(self, filename):
11 self.filename = filename
12 # This will create it if it does not exist already
13 unbuffered = 0
14 self.handle = open(filename, 'a+', unbuffered)
16 def acquire(self):
17 fcntl.flock(self.handle, fcntl.LOCK_EX)
19 # will throw IOError if unavailable
20 def try_acquire(self):
21 fcntl.flock(self.handle, fcntl.LOCK_NB | fcntl.LOCK_EX)
23 def release(self):
24 fcntl.flock(self.handle, fcntl.LOCK_UN)
26 def __del__(self):
27 self.handle.close()