def _fetch_images(self, fetch_func, **kwargs):
        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 KeyError:
            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
Paginate through results from glance server
dataset/ETHPy150Open nii-cloud/dodai-compute/nova/image/glance.py/GlanceImageService._fetch_images