httpclient.py 文件源码

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

项目:gulper 作者: QuantifiedSelfless 项目源码 文件源码
def fetch(url, *args, **kwargs):
    retry_max = kwargs.pop('retry_max', 5)
    retry = 0
    while True:
        try:
            result = yield http_client.fetch(url, *args, **kwargs)
            return result
        except HTTPError as e:
            if e.code == 599:
                retry += 1
                if retry < retry_max:
                    logger.error(
                        "Timeout in request: "
                        "sleeping for {}: {}".format(2**retry, url)
                    )
                    yield gen.sleep(2**retry)
                    continue
            raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号