def iterate_forever(func, *args, **kwargs):
output = func(*args, **kwargs)<EOL>while True:<EOL><INDENT>try:<EOL><INDENT>playlist_item = next(output)<EOL>playlist_item.prepare_playback()<EOL>yield playlist_item<EOL><DEDENT>except StopIteration:<EOL><INDENT>output = func(*args, **kwargs)<EOL><DEDENT><DEDENT>
Iterate over a finite iterator forever

    When the iterator is exhausted will call the function again to generate a
    new iterator and keep iterating.