http_client.py 文件源码

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

项目:pnu 作者: erasaur 项目源码 文件源码
def get_json (self, url, timeout=None):
        if timeout is None:
            timeout = pub_config["http"]["timeout_seconds"]

        result = {}
        try:
            with aiohttp.Timeout(timeout):
                async with self._session.get(url) as resp:
                    try:
                        res = await resp.json()
                    except Exception as e:
                        logging.info("failed decoding response, got exception: {}".format(e))
                        res = {}
                    result["res"] = res
                    result["status"] = resp.status
        except TimeoutError as e:
            logging.info("HTTP timeout ({}) with error: {}".format(url, e)) 

        return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号