Recursive method to work around the hard limit of 10 items per call.
490545
def _iterate_list(self, include_claimed, echo, marker, limit):
        
        ret = []
        if limit is None:
            this_limit = MSG_LIMIT
        else:
            this_limit = min(MSG_LIMIT, limit)
            limit = limit - this_limit
        uri = "/%s?include_claimed=%s&echo=%s" % (self.uri_base,
                json.dumps(include_claimed), json.dumps(echo))
        qs_parts = []
        if marker is not None:
            qs_parts.append("marker=%s" % marker)
        if this_limit is not None:
            qs_parts.append("limit=%s" % this_limit)
        if qs_parts:
            uri = "%s&%s" % (uri, "&".join(qs_parts))
        resp, resp_body = self._list(uri, return_raw=True)
        if not resp_body:
            return ret
        messages = resp_body.get(self.plural_response_key, [])
        ret = [QueueMessage(manager=self, info=item) for item in messages]
        marker = _parse_marker(resp_body)

        loop = 0
        if ((limit is None) or limit > 0) and marker:
            loop += 1
            ret.extend(self._iterate_list(include_claimed, echo, marker, limit))
        return ret
814329
def consume(iterator, n):
    ""
    # Use functions that consume iterators at C speed.
    if n is None:
        # feed the entire iterator into a zero-length deque
        collections.deque(iterator, maxlen=0)
    else:
        # advance to the empty slice starting at position n
        next(islice(iterator, n, n), None)
276471
def handle_multiple_callers(data, key, default=None, require_bam=True):
    
    callers = get_variantcaller(data, key, default, require_bam=require_bam)
    if isinstance(callers, six.string_types):
        return [data]
    elif not callers:
        return []
    else:
        out = []
        for caller in callers:
            base = copy.deepcopy(data)
            if not base["config"]["algorithm"].get("orig_%s" % key):
                base["config"]["algorithm"]["orig_%s" % key] = \
                  base["config"]["algorithm"][key]
            base["config"]["algorithm"][key] = caller
            # if splitting by variant caller, also split by jointcaller
            if key == "variantcaller":
                jcallers = get_variantcaller(data, "jointcaller", [])
                if isinstance(jcallers, six.string_types):
                    jcallers = [jcallers]
                if jcallers:
                    base["config"]["algorithm"]["orig_jointcaller"] = jcallers
                    jcallers = [x for x in jcallers if x.startswith(caller)]
                    if jcallers:
                        base["config"]["algorithm"]["jointcaller"] = jcallers[0]
                    else:
                        base["config"]["algorithm"]["jointcaller"] = False
            out.append(base)
        return out
370850
def _max_recursion_depth(obj):
    ''' 
    '''
    neurites = obj.neurites if hasattr(obj, 'neurites') else [obj]

    return max(sum(1 for _ in neu.iter_sections()) for neu in neurites)
969881
def repeat_call(func, retries, *args, **kwargs):
    '''
    
    '''
    retries = max(0, int(retries))
    try_num = 0
    while True:
        if try_num == retries:
            return func(*args, **kwargs)
        else:
            try:
                return func(*args, **kwargs)
            except Exception as e:
                if isinstance(e, KeyboardInterrupt):
                    raise e
                try_num += 1
1083318
def _chunks(self, items, limit):
        
        for i in range(0, len(items), limit):
            yield items[i:i + limit]
17771
function RecursivePaginatedWebCall(client, method, property, options = {}) {
    /**
     * store all entries
     */
    var data = [];

    /**
     * count of recursive calls required
     */
    var rcount = 0;

    return new Promise((resolve, reject) => {
      function recurse() {
        rcount++;
        client
          .apiCall(method, options)
          .then(res => {
            data = data.concat(res[property]);

            /**
             * if more pages, keep going otherwise resolve the promise
             */
            if (
              res.response_metadata &&
              res.response_metadata.next_cursor &&
              res.response_metadata.next_cursor !== ""
            ) {
              options.cursor = res.response_metadata.next_cursor;

              // keep recursing
              recurse();
            } else {
              resolve(data);
            }
          })
          .catch(e => {
            reject(e);
          });
      }

      // start recursion
      recurse();
    });
  }
173448
def slice_into_pieces(seq, n):
    """"""
    length = len(seq)
    if length % n == 0:
        size = length // n
    else:
        size = length // n + 1
    for it in slice_by_size(seq, size):
        yield it
811126
def apply_limit(self):
    ''''''
    self._ensure_modification_is_safe()

    if self.query.limit is not None:
      self._iterable = limit_gen(self.query.limit, self._iterable)
275418
private static void recursiveSet(CopycatClient client) {
    client.submit(new SetCommand(UUID.randomUUID().toString())).whenComplete((result, error) -> {
      client.context().schedule(Duration.ofSeconds(5), () -> recursiveSet(client));
    });
  }
113144
public final Tuple10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> limit10() {
        return this;
    }
404345
public static <E extends Comparable<E>> void recursiveQuickSort(List<E> array, int startIdx,
      int endIdx) {

    int idx = partition(array, startIdx, endIdx);

    // Recursively call quicksort with left part of the partitioned array
    if (startIdx < idx - 1) {
      recursiveQuickSort(array, startIdx, idx - 1);
    }

    // Recursively call quick sort with right part of the partitioned array
    if (endIdx > idx) {
      recursiveQuickSort(array, idx, endIdx);
    }
  }
409814
def do_less_expensive_things(number):
    
    result = yield batch_accumulate(1000, expensive(number))
    total = reduce(add, result, 0)
    log.msg("only for {}: {}".format(number, total))
    defer.returnValue(total)
91347
def _recursive_merged_items(self, index):
        
        subdirs = [os.path.join(d, "parts", str(index)) for d in self.localdirs]
        m = ExternalMerger(self.agg, self.memory_limit, self.serializer, subdirs,
                           self.scale * self.partitions, self.partitions, self.batch)
        m.pdata = [{} for _ in range(self.partitions)]
        limit = self._next_limit()

        for j in range(self.spills):
            path = self._get_spill_dir(j)
            p = os.path.join(path, str(index))
            with open(p, 'rb') as f:
                m.mergeCombiners(self.serializer.load_stream(f), 0)

            if get_used_memory() > limit:
                m._spill()
                limit = self._next_limit()

        return m._external_items()
271173
function recursiveCall(i, callback) {
            if(i >= _modules.length) {
                callback();
            } else {
                _modules[i].check(req, res, function () {
                    recursiveCall(++i, callback);
                })
            }
        }
905943
def MapItemsIterator(function, items):
  """"""
  return ItemsIterator(
      items=map(function, items), total_count=items.total_count)
612218
def call_for_nodes(node, callback, recursive=False):
    """"""
    result = callback(node)
    if recursive and not result:
        for child in get_child_nodes(node):
            call_for_nodes(child, callback, recursive)