(pseudo_lock_path, pseudo_lock_fd_return)
Try to acquire the lock and return a boolean indicating whether the attempt
  was successful. If the attempt was successful, pseudo_lock_fd_return, which
  should be an empty array, will be modified to contain a single entry: the file
  descriptor of the (now acquired) lock file.

  This whole operation is guarded with the global cloud storage lock, which
  prevents race conditions that might otherwise cause multiple processes to
  believe they hold the same pseudo lock (see _FileLock for more details).
Try to acquire the lock and return a boolean indicating whether the attempt
  was successful. If the attempt was successful, pseudo_lock_fd_return, which
  should be an empty array, will be modified to contain a single entry: the file
  descriptor of the (now acquired) lock file.
Try to acquire the lock and return a boolean indicating whether the attempt was successful . If the attempt was successful pseudo_lock_fd_return which should be an empty array will be modified to contain a single entry : the file descriptor of the ( now acquired ) lock file .
def _AttemptPseudoLockAcquisition(pseudo_lock_path, pseudo_lock_fd_return):
  """Try to acquire the lock and return a boolean indicating whether the attempt
  was successful. If the attempt was successful, pseudo_lock_fd_return, which
  should be an empty array, will be modified to contain a single entry: the file
  descriptor of the (now acquired) lock file.

  This whole operation is guarded with the global cloud storage lock, which
  prevents race conditions that might otherwise cause multiple processes to
  believe they hold the same pseudo lock (see _FileLock for more details).
  """
  pseudo_lock_fd = None
  try:
    with open(_CLOUD_STORAGE_GLOBAL_LOCK) as global_file:
      with lock.FileLock(global_file, lock.LOCK_EX | lock.LOCK_NB):
        # Attempt to acquire the lock in a non-blocking manner. If we block,
        # then we'll cause deadlock because another process will be unable to
        # acquire the cloud storage global lock in order to release the pseudo
        # lock.
        pseudo_lock_fd = open(pseudo_lock_path, 'w')
        lock.AcquireFileLock(pseudo_lock_fd, lock.LOCK_EX | lock.LOCK_NB)
        pseudo_lock_fd_return.append(pseudo_lock_fd)
        return True
  except (lock.LockException, IOError):
    # We failed to acquire either the global cloud storage lock or the pseudo
    # lock.
    if pseudo_lock_fd:
      pseudo_lock_fd.close()
    return False
def _AttemptPseudoLockAcquisition ( pseudo_lock_path , pseudo_lock_fd_return ) : pseudo_lock_fd = None try : with open ( _CLOUD_STORAGE_GLOBAL_LOCK ) as global_file : with lock . FileLock ( global_file , lock . LOCK_EX | lock . LOCK_NB ) : # Attempt to acquire the lock in a non-blocking manner. If we block, # then we'll cause deadlock because another process will be unable to # acquire the cloud storage global lock in order to release the pseudo # lock. pseudo_lock_fd = open ( pseudo_lock_path , 'w' ) lock . AcquireFileLock ( pseudo_lock_fd , lock . LOCK_EX | lock . LOCK_NB ) pseudo_lock_fd_return . append ( pseudo_lock_fd ) return True except ( lock . LockException , IOError ) : # We failed to acquire either the global cloud storage lock or the pseudo # lock. if pseudo_lock_fd : pseudo_lock_fd . close ( ) return False