0
点赞
收藏
分享

微信扫一扫

同步库与协程的共同使用


# coding: utf-8
# @Time : 2022-05-17 21:53
# @Author : AngDH
import asyncio

import requests


async def main():
loop = asyncio.get_event_loop()
future1 = loop.run_in_executor(None, requests.get, "http://www.baidu.com")
future2 = loop.run_in_executor(None, requests.get, "http://www.taobao.com")

response1 = await future1
response2 = await future2

print(response1.status_code,"111111")
print(response2.status_code,"22222")



asyncio.run(main())





举报

相关推荐

0 条评论