def load_and_increment_counter(name, period=datetime.now(), period_types=[PeriodType.ALL], namespace='default', delta=1, batch_size=None):    
    # Warning: There is a race condition here. If two processes try to load
    # the same value from the datastore, one's update may be lost.
    # TODO: Think more about whether we care about this...
    
    for period_type in period_types:
        current_count = None
        
        result = None
        partial_key = LivecountCounter.PartialKeyName(period_type, period, name)
        if delta >= 0:
            result = memcache.incr(partial_key, delta, namespace=namespace)
        else: # Since increment by negative number is not supported, convert to decrement
            result = memcache.decr(partial_key, -delta, namespace=namespace)
        
        if result is None:
            # See if this counter already exists in the datastore
            full_key = LivecountCounter.KeyName(namespace, period_type, period, name)
            record = LivecountCounter.get_by_key_name(full_key)
            if record:
                # Load last value from datastore
                new_counter_value = record.count + delta
                if new_counter_value < 0: new_counter_value = 0  # To match behavior of memcache.decr(), don't allow negative values
                memcache.add(partial_key, new_counter_value, namespace=namespace)
                if batch_size: current_count = record.count
            else:
                # Start new counter
                memcache.add(partial_key, delta, namespace=namespace)
                if batch_size: current_count = delta
        else:
            if batch_size: current_count = memcache.get(partial_key, namespace=namespace)
            
        # If batch_size is set, only try creating one worker per batch
        if not batch_size or (batch_size and current_count % batch_size == 0):
            if memcache.add(partial_key + '_dirty', delta, namespace=namespace):
                #logging.info("Adding task to taskqueue. counter value = " + str(memcache.get(partial_key, namespace=namespace)))
                taskqueue.add(queue_name='livecount-writebacks', url='/livecount/worker', params={'name': name, 'period': period, 'period_type': period_type, 'namespace': namespace}) # post parameter
Get the scheduler for the next build that has successfully completed build preparation.
dataset/ETHPy150Open gregbayer/gae-livecount/livecount/counter.py/load_and_increment_counter--crossover with--dataset/ETHPy150Open box/ClusterRunner/app/master/build_request_handler.py/BuildRequestHandler.next_prepared_build_scheduler