Your code is looping infinitely over the data (that’s why it looks like your process is hung). You can limit the number of times you ‘refresh’ your iterator  (eg: 100) by replacing while True with for _ in range(100).