Created
December 2, 2022 17:46
-
-
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
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
''' | |
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