def _run_service_query(self, query, query_function):
        results = []
        while True:
            try:
                response = query_function(query.ToStatement())
            except Exception as e:
                raise ParselmouthException(
                    "Error running query: {0}. Got Error: {1}".format(
                        query.ToStatement(),
                        str(e)
                    )
                )
            if 'results' in response:
                logging.info(
                    'Statement %s returned %d results',
                    query.ToStatement(),
                    len(response['results']),
                )
                results += response['results']
                query.offset += SUGGESTED_PAGE_LIMIT
            else:
                break

        return results
Run a series of chunked DFP queries until all results
dataset/ETHPy150Open chartbeat-labs/parselmouth/parselmouth/adapters/dfp/client.py/DFPClient._run_service_query