mapreduce/quota.py
def consume(self, bucket, amount, consume_some=False):
    """Consume amount from quota bucket.

    Args:
      bucket: quota bucket as string.
      amount: amount to consume.
      consume_some: specifies behavior in case of not enough quota. If False,
        the method will leave quota intact and return 0. If True, will try to
        consume as much as possible.

    Returns:
      Amount of quota consumed.
    """
    new_quota = self.memcache_client.decr(
        bucket, delta=amount, initial_value=_OFFSET, namespace=_QUOTA_NAMESPACE)

    if new_quota >= _OFFSET:
      return amount

    if consume_some and _OFFSET - new_quota < amount:
      # we still can consume some
      self.put(bucket, _OFFSET - new_quota)
      return amount - (_OFFSET - new_quota)
    else:
      self.put(bucket, amount)
      return 0
Consume amount from quota bucket.

    Args:
      bucket: quota bucket as string.
      amount: amount to consume.
      consume_some: specifies behavior in case of not enough quota. If False,
        the method will leave quota intact and return 0. If True, will try to
        consume as much as possible.

    Returns:
      Amount of quota consumed.
    
Consume amount from quota bucket.
Consume amount from quota bucket .
def consume(self, bucket, amount, consume_some=False):
    new_quota = self.memcache_client.decr(
        bucket, delta=amount, initial_value=_OFFSET, namespace=_QUOTA_NAMESPACE)
    if new_quota >= _OFFSET:
      return amount
    if consume_some and _OFFSET - new_quota < amount:
      self.put(bucket, _OFFSET - new_quota)
      return amount - (_OFFSET - new_quota)
    else:
      self.put(bucket, amount)
      return 0
def consume ( self , bucket , amount , consume_some = False ) : new_quota = self . memcache_client . decr ( bucket , delta = amount , initial_value = _OFFSET , namespace = _QUOTA_NAMESPACE ) if new_quota >= _OFFSET : return amount if consume_some and _OFFSET - new_quota < amount : self . put ( bucket , _OFFSET - new_quota ) return amount - ( _OFFSET - new_quota ) else : self . put ( bucket , amount ) return 0
Consume amount from quota bucket.
Consume amount from quota bucket .
"""Consume amount from quota bucket.

    Args:
      bucket: quota bucket as string.
      amount: amount to consume.
      consume_some: specifies behavior in case of not enough quota. If False,
        the method will leave quota intact and return 0. If True, will try to
        consume as much as possible.

    Returns:
      Amount of quota consumed.
    """ # we still can consume some
Amount of quota consumed.
Amount of quota consumed .
self
bucket
quota bucket as string.
quota bucket as string .
amount
amount to consume.
amount to consume .
consume_some
specifies behavior in case of not enough quota. If False,
the method will leave quota intact and return 0. If True, will try to
consume as much as possible.
specifies behavior in case of not enough quota . If False the method will leave quota intact and return 0 . If True will try to consume as much as possible .