'Attempt to acquire some amount of quota.
Args:
name: [string] The name of the resource we\'re acquiring.
count: [int] The amount of the resource
Returns:
The amount we were given. This is either all or none. If non-zero
but less than we asked for, then it gave us the max quota it has.
In order for this to be the case, it must have all the quota available.
Otherwise it will return 0.'

def __acquire_resource_or_none(self, name, count):

    have = self.__counts.get(name)
    if (have is None):
        return count
    if (have >= count):
        self.__counts[name] = (have - count)
        return count
    max_count = self.__max_counts[name]
    if (have == max_count):
        logging.warning('Quota    %s    has    a    max    of    %d    but    %d    is    desired.    Acquiring    all    the    quota    as    a    best    effort.', name, max_count, count)
        self.__counts[name] = 0
        return have
    logging.warning('Quota    %s    has    %d    remaining,    but    %d    are    needed.    Rejecting    the    request    for    now.', name, have, count)
    return 0
