'Prefetch the tasks for the next batch and dispatch them.
The effective size of the batch is computed here.
If there are no more jobs to dispatch, return False, else return True.
The iterator consumption and dispatching is protected by the same
lock so calling this function should be thread safe.'

def dispatch_one_batch(self, iterator):

    if (self.batch_size == 'auto'):
        batch_size = self._backend.compute_batch_size()
    else:
        batch_size = self.batch_size
    with self._lock:
        tasks = BatchedCalls(itertools.islice(iterator, batch_size))
        if (len(tasks) == 0):
            return False
        else:
            self._dispatch(tasks)
            return True
