(self)
Obtain the backup lock to ensure that several backups are not
        run in parallel. If someone already has the lock we check if
        this is from a previous (failed) backup. If that is the case,
        the lock is released and re-obtained.
Obtain the backup lock to ensure that several backups are not
        run in parallel. If someone already has the lock we check if
        this is from a previous (failed) backup. If that is the case,
        the lock is released and re-obtained.
Obtain the backup lock to ensure that several backups are not run in parallel . If someone already has the lock we check if this is from a previous ( failed ) backup . If that is the case the lock is released and re - obtained .
def remote_xlock(self):
        """
        Obtain the backup lock to ensure that several backups are not
        run in parallel. If someone already has the lock we check if
        this is from a previous (failed) backup. If that is the case,
        the lock is released and re-obtained.
        """
        xlock_cmd = "xlock %d" % os.getpid()
        ret = self.remote_walmgr(xlock_cmd, allow_error=True)
        if ret[0] != 0:
            # lock failed.
            try:
                lock_pid = int(ret[1])
            except ValueError:
                self.log.fatal("Invalid pid in backup lock")
                sys.exit(1)

            try:
                os.kill(lock_pid, 0)
                self.log.fatal("Backup lock already taken")
                sys.exit(1)
            except OSError:
                # no process, carry on
                self.remote_walmgr("xrelease")
                self.remote_walmgr(xlock_cmd)
def remote_xlock ( self ) : xlock_cmd = "xlock %d" % os . getpid ( ) ret = self . remote_walmgr ( xlock_cmd , allow_error = True ) if ret [ 0 ] != 0 : # lock failed. try : lock_pid = int ( ret [ 1 ] ) except ValueError : self . log . fatal ( "Invalid pid in backup lock" ) sys . exit ( 1 ) try : os . kill ( lock_pid , 0 ) self . log . fatal ( "Backup lock already taken" ) sys . exit ( 1 ) except OSError : # no process, carry on self . remote_walmgr ( "xrelease" ) self . remote_walmgr ( xlock_cmd )