Skip to content

Instantly share code, notes, and snippets.

@im-noob
Created December 2, 2022 17:46
Show Gist options
  • Save im-noob/c42e943ecf4a254836598439fe865fa8 to your computer and use it in GitHub Desktop.
Save im-noob/c42e943ecf4a254836598439fe865fa8 to your computer and use it in GitHub Desktop.
millions or request with payload and headers with python request and httio
'''
Reuire More than 12 GB ram to process all the request..
!pip install nest-asyncio
'''
import asyncio
from aiohttp import ClientSession
import nest_asyncio
nest_asyncio.apply()
async def hello(url, data, headers):
async with ClientSession() as session:
async with session.post(url, json=data, headers=headers) as response:
# response = await response.read()
# print(response)
pass
loop = asyncio.get_event_loop()
tasks = []
for i in range(1000_000):
print('Request no',i)
task = asyncio.ensure_future(hello(url, payload, headers))
tasks.append(task)
loop.run_until_complete(asyncio.wait(tasks))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment