def chunkiter(objs, n=100):
    """
    Chunk an iterator of unknown size. The optional
    keyword 'n' sets the chunk size (default 100).
    """

    objs = iter(objs)
    try:
        while (1):
            chunk = []
            while len(chunk) < n:
                chunk.append(six.next(objs))
            yield chunk
    except StopIteration:
        pass
    if len(chunk):
        yield chunk