from async_retrying import retry
import aiohttp
import asyncio @retry(attempts=6)
async def fetch():
print(1)
async with aiohttp.ClientSession() as session:
async with session.get("https://wwww.baidu.com", verify_ssl=False) as req:
source = await req.text()
1 / 0
return source async def main():
res = await fetch()
return res if __name__ == '__main__':
loop = asyncio.get_event_loop()
try:
res = loop.run_until_complete(main())
print(res)
finally:
loop.close()

async_retrying的更多相关文章

随机推荐

  1. Map_占位符(嗨没想好怎么起名字)

    Map 是很好的集合,为我们带来了在其他语言(比如 Perl)中经常可见的好用的键/值对集合.JDK 以 HashMap 的形式为我们提供了方便的 Map 实现,它在内部使用哈希表实现了对键的对应值的 ...

  2. powershell 中常用cmd,unix命令(get-alias)

    powershell 中常用cmd,unix命令(get-alias) Get-Content Alias cat -> Get-Content Alias gc -> Get-Conte ...

  3. Mysql查看表的建表语句

    已查询Test的建表语句为例: SHOW CREATE TABLE TEST

  4. webpack3.x版本实战案例【基础配置篇】(一)

    本文旨在通过一个一个实战例子来学习webpack如何配置,更加深入的学习webpack在实战项目中如何配置. 我们学习哪些配置呢? [基础配置] 打包JS 编译ES6 编译typeScript 打包公 ...

  5. windows平台在tomcat中启动cas报错解决

    windows平台在tomcat中启动cas报错: Caused by: java.lang.UnsatisfiedLinkError: Could not load library. Reasons ...

  6. 开发更健壮python程序的一些工具

    在众多语言中, Java 生态系统发展得最好, 比如异常logging报警, 比如性能监控工具. Python其实生态也不错, 这里列出一些出色的工具. LogBook, 并结合 raven-pyth ...

  7. JS获得元素相对位置坐标getBoundingClientRect()

    getBoundingClientRect用于获取某个元素相对于视窗的位置集合.集合中有top, right, bottom, left等属性. 1.语法:这个方法没有参数. rectObject = ...

  8. IScroll基本用法

    一.为了防止手机上卡顿:1.从新设置一下焦点.2. <script>try { window.PointerEvent = undefined; } catch (e) { } </ ...

  9. [译]Walkthrough: Using MSBuild

    原文 MSBuild是微软VS的Build平台. 你可以在Visual Studio或Windows命令行中运行MSBuild.在这我们使用VS创建一个MSBuild项目.你可以在VS中编辑项目文件, ...

  10. Spring 快速开始 启动Spring

    [启动Spring必须配置] [web.xml部署描述符方式] 1.配置Servlet级别上下文 <servlet> <servlet-name>springDispatche ...