(self)
acquire the lock; else raise LockfileLockedException.
acquire the lock; else raise LockfileLockedException.
acquire the lock ; else raise LockfileLockedException .
def acquire(self):
        """acquire the lock; else raise LockfileLockedException."""

        try:
            fcntl.flock(self.f, fcntl.LOCK_EX|fcntl.LOCK_NB)
        except IOError, e:
            if e.errno == EWOULDBLOCK:
                raise LockfileLockedException(
                  "cannot acquire lock on %s." % self.lockfile)
            else:
                raise
        # unlock upon exit
        fcntl.fcntl(self.f, fcntl.F_SETFD, 1)
        # truncate and write the pid
        os.ftruncate(self.f, 0)
        os.write(self.f, str(self.pid) + '\n')
def acquire ( self ) : try : fcntl . flock ( self . f , fcntl . LOCK_EX | fcntl . LOCK_NB ) except IOError , e : if e . errno == EWOULDBLOCK : raise LockfileLockedException ( "cannot acquire lock on %s." % self . lockfile ) else : raise # unlock upon exit fcntl . fcntl ( self . f , fcntl . F_SETFD , 1 ) # truncate and write the pid os . ftruncate ( self . f , 0 ) os . write ( self . f , str ( self . pid ) + '\n' )