utils.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:aws-cfn-plex 作者: lordmuffin 项目源码 文件源码
def retrieve_uri(self, relative_uri):
        """Retrieve JSON metadata from ECS metadata.

        :type relative_uri: str
        :param relative_uri: A relative URI, e.g "/foo/bar?id=123"

        :return: The parsed JSON response.

        """
        full_url = self._full_url(relative_uri)
        headers = {'Accept': 'application/json'}
        attempts = 0
        while True:
            try:
                return self._get_response(full_url, headers, self.TIMEOUT_SECONDS)
            except MetadataRetrievalError as e:
                logger.debug("Received error when attempting to retrieve "
                             "ECS metadata: %s", e, exc_info=True)
                self._sleep(self.SLEEP_TIME)
                attempts += 1
                if attempts >= self.RETRY_ATTEMPTS:
                    raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号