ancient-stone-50795
03/23/2016, 8:44 PMbored-art-40741
03/23/2016, 9:38 PMbored-art-40741
03/23/2016, 9:38 PMbored-art-40741
03/23/2016, 9:38 PM@contextmanager
def owner_printing_file_lock(path, blocking=True, timeout=None):
lock = InterProcessLock(path)
if not lock.acquire(blocking=False):
with open(lock.path, 'rb') as f:
lockfile_contents = f.read().decode('utf-8', 'replace')
print('Waiting on pants process to complete: {}'.format(lockfile_contents), file=sys.stderr)
else:
lock.release()
with lock.acquire(blocking=blocking, timeout=timeout):
with open(lock.path, 'wb') as f:
current_process = psutil.Process()
message = '{} ({})'.format(current_process.pid, ' '.join(current_process.cmdline()))
f.write(message.encode('utf-8'))
yield lock
with open(lock.path, 'w'):
pass
bored-art-40741
03/23/2016, 9:39 PMbored-art-40741
03/23/2016, 9:42 PMInterProcessLock
codewitty-crayon-22786
03/23/2016, 9:44 PMblocking=False
, aren't you throwing away the handle?witty-crayon-22786
03/23/2016, 9:45 PMwitty-crayon-22786
03/23/2016, 9:45 PMwitty-crayon-22786
03/23/2016, 9:47 PMwitty-crayon-22786
03/23/2016, 9:47 PMbored-art-40741
03/23/2016, 9:53 PMbored-art-40741
03/23/2016, 9:53 PMbored-art-40741
03/23/2016, 9:53 PMbored-art-40741
03/23/2016, 9:54 PMbored-art-40741
03/23/2016, 9:54 PMbored-art-40741
03/23/2016, 9:54 PMbored-art-40741
03/23/2016, 9:54 PMbored-art-40741
03/23/2016, 9:54 PMbored-art-40741
03/23/2016, 10:00 PMbored-art-40741
03/23/2016, 10:00 PMwitty-crayon-22786
03/23/2016, 10:02 PMwitty-crayon-22786
03/23/2016, 10:02 PMbored-art-40741
03/23/2016, 10:02 PMwitty-crayon-22786
03/23/2016, 10:02 PMbored-art-40741
03/23/2016, 10:02 PMbored-art-40741
03/23/2016, 10:02 PMwitty-crayon-22786
03/23/2016, 10:03 PMwitty-crayon-22786
03/23/2016, 10:03 PMbored-art-40741
03/23/2016, 10:03 PM