def split_buffer(stream, splitter=None, decoder=lambda a: a):
    splitter = splitter or line_splitter
    buffered = six.text_type('')

    for data in stream_as_text(stream):
        buffered += data
        while True:
            buffer_split = splitter(buffered)
            if buffer_split is None:
                break

            item, buffered = buffer_split
            yield item

    if buffered:
        yield decoder(buffered)
Given a generator which yields strings and a splitter function,
dataset/ETHPy150Open docker/compose/compose/utils.py/split_buffer