如何使用python进行并行请求?
到目前为止,我的代码:
x = ("address")
x.signin(signin.request())
# this code signs in the user and generate the response how to do a parallel response.
查看了这些内容,但不知道在哪里使用
import asyncio
import requests
async def main():
loop = asyncio.get_event_loop()
futures = [
loop.run_in_executor(
None,
requests.get,
'http://example.org/'
)
for i in range(20)
]
for response in await asyncio.gather(*futures):
pass
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
还查看了此线程:
What is the fastest way to send 100,000 HTTP requests in Python?