def __init__(self, path):
+ # Open lockfile for writing without truncation:
+ # If the file doesn't exist, IOError is raised; Use a+ instead.
+ # Note that there may be a race here. Multiple processes
+ # could fail on the r+ open and open the file a+, but only
+ # one will get the the lock and write a pid.
fp.write(" %s\n" % os.getpid())