def read_chunks(filepath, chunk_size):
    """Generator that yields chunks from file"""
    try:
        with open(filepath, 'rb') as f:
            while True:
                chunk = f.read(chunk_size)
                if chunk:
                    yield chunk
                else:
                    break  # EOF
    except OSError as e:
        raise error.ReadError(e.errno, filepath)
Generator that yields chunks from file