code: def valid_lock(self):
          
  
          lock_pid = self.get_lock_pid()
  
          # If we're unable to get lock_pid
          if lock_pid is None:
              return False
  
          # this is our process
          if self._pid == lock_pid:
              return True
  
          # it is/was another process
          # see if it is running
          try:
              os.kill(lock_pid, 0)
          except OSError:
              self.release()
              return False
  
          # it is running
          return True
docs: See if the lock exists and is left over from an old process.