#!/usr/bin/python3 import fcntl import time print('Wait until we have the lock') with open('/var/tmp/testing', 'ab') as fd: fcntl.lockf(fd, fcntl.LOCK_EX) print('lock acquired by waiter')