How to train RNN with infinite sequences?

I have got a possible solution here. Please let me know if there is any other suggestion. Thanks!