def consume(self, amount=1):
    """Consume quota.

    Args:
      amount: amount of quota to be consumed as int.

    Returns:
      True if quota was successfully consumed, False if there's not enough
      quota.
    """
    while self.quota < amount:
      delta = self.quota_manager.consume(self.bucket, self.batch_size,
                                         consume_some=True)
      if not delta:
        return False
      self.quota += delta

    self.quota -= amount
    return True
Consume quota.

    Args:
      amount: amount of quota to be consumed as int.

    Returns:
      True if quota was successfully consumed, False if there's not enough
      quota.
    
mapreduce/quota.py