# Open lockfile for writing without truncation:
+ fp = open(path, 'r+')
# 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 = open(path, 'a+')
- fp.write(" %s\n" % os.getpid())
+ self.fp.write(" %s\n" % os.getpid())
if not hasattr(self, 'fp'):