Created
May 4, 2022 13:09
-
-
Save Johnetordoff/7502ac92e292be9874e952c35d2acb3c to your computer and use it in GitHub Desktop.
Hit the throttle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import requests | |
| from aiohttp import ClientSession, http_exceptions | |
| async def hit(): | |
| async with ClientSession(cookies={'cookie':' ssdfd'}) as session: | |
| async with session.get('http://localhost:8000/v2/') as resp: | |
| return resp.status | |
| tasks = [hit(), hit(), hit(), hit(), hit(),hit(), hit(), hit(), hit(), hit(), hit(), hit(), hit(), hit(), hit(),hit(), hit(), hit(), hit(), hit()] | |
| print(asyncio.gather(*tasks)) | |
| async def main(): | |
| ret = await asyncio.gather(*tasks) | |
| print(ret) | |
| asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment