def poll(self, max_time=60):
        logger.info(u"polling collection '{collection_id}'".format(
                collection_id=self.collection_id))

        still_updating = True
        tries = 0
        start = time.time()
        while still_updating:
            url = api_url + "/collection/" + self.collectionId
            resp = requests.get(url, config={'verbose': None})
            try:
                items = json.loads(resp.text)["items"]
            except __HOLE__:
                items = []
                logger.warning(u"get '{url}' returned no json, only '{resp}') ".format(
                        url=url, resp=resp.text))

            tries += 1

            currently_updating_flags = [True for item in items if
                                        item["currently_updating"]]
            num_currently_updating = len(currently_updating_flags)
            num_finished_updating = len(items) - num_currently_updating

            logger.info(u"{num_done} of {num_total} items done updating after {tries} requests.".format(
                    num_done=num_finished_updating, num_total=len(items), tries=tries))
            logger.debug(u"got these items back: " + str(items))

            elapsed = time.time() - start
            if resp.status_code == 200:
                logger.info(u"collection '{id}' with {num_items} items finished updating in {elapsed} seconds.".format(
                        id=self.collection_id, num_items=len(items), elapsed=round(elapsed, 2)))
                return True
            elif elapsed > max_time:
                raise Exception(
                    "max polling time ({max} secs) exceeded for collection {id}. These items didn't update: {item_ids}".format(
                        max=max_time,
                        id=self.collection_id,
                        item_ids=", ".join([item["_id"] for item in items if
                                            item["currently_updating"]])))
                return False

            sleep(0.5)
dataset/ETHPy150Open Impactstory/total-impact-core/totalimpact/fakes.py/ReportPage.poll