def split_by_marker(f, marker='-MARKER-', block_size=4096):
    current = ''
while True:
    block = f.read(block_size)
if not block:
    yield current
return
current += block
while True:
    markerpos = current.find(marker)
if markerpos < 0:
    break
yield current[:markerpos]
current = current[markerpos + len(marker):]
How to read a big binary file and split its content by some marker