app.py 文件源码

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

项目:arq 作者: samuelcolvin 项目源码 文件源码
def download_content(self, url, count):
        total_size = 0
        errors = []
        start = time()
        for _ in range(count):
            try:
                async with self.session.get(url) as r:
                    content = await r.read()
                    total_size += len(content)
                    if r.status != 200:
                        errors.append(f'{r.status} length: {len(content)}')
            except ClientError as e:
                errors.append(f'{e.__class__.__name__}: {e}')
        output = f'{time() - start:0.2f}s, {count} downloads, total size: {total_size}'
        if errors:
            output += ', errors: ' + ', '.join(errors)
        await self.redis.rpush(R_OUTPUT, output.encode())
        return total_size
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号