#!/usr/bin/env python #coding: utf-8 import fcntl fd = open("lockfile.lock", "w") fcntl.flock(fd,fcntl.LOCK_EX) # process fcntl.flock(fd,fcntl.LOCK_UN) fd.close()