def _buffered_generation_thread(source_gen, buffer_, sentinal):
    """ helper for buffered_generator """
    for data in source_gen:
        buffer_.put(data, block=True)
    # sentinel: signal the end of the iterator
    buffer_.put(sentinal)