def _fetch_images(self, fetch_func, **kwargs):
        """Paginate through results from glance server"""
        images = fetch_func(**kwargs)

        if not images:
            # break out of recursive loop to end pagination
            return

        for image in images:
            yield image

        try:
            # attempt to advance the marker in order to fetch next page
            kwargs['marker'] = images[-1]['id']
        except __HOLE__:
            raise exception.ImagePaginationFailed()

        try:
            kwargs['limit'] = kwargs['limit'] - len(images)
            # break if we have reached a provided limit
            if kwargs['limit'] <= 0:
                return
        except KeyError:
            # ignore missing limit, just proceed without it
            pass

        for image in self._fetch_images(fetch_func, **kwargs):
            yield image
dataset/ETHPy150Open nii-cloud/dodai-compute/nova/image/glance.py/GlanceImageService._fetch_images