Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Johnetordoff/7502ac92e292be9874e952c35d2acb3c to your computer and use it in GitHub Desktop.
Save Johnetordoff/7502ac92e292be9874e952c35d2acb3c to your computer and use it in GitHub Desktop.
Hit the throttle
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