>>> import io
>>>
>>> b = b'abcde' * 10
>>>
>>> stream = io.BytesIO(b)
>>> while True:
... block = stream.read(8)
... if not block:
... break
... print(block)
...
b'abcdeabc'
b'deabcdea'
b'bcdeabcd'
b'eabcdeab'
b'cdeabcde'
b'abcdeabc'
b'de'
>>>