Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from aiohttp import ClientSession
from pypeln import io
import asyncio
import sys
async def fetch(url, session):
async with session.get(url) as response:
return await response.read()
async def main():
r = 10
url = "http://google.com"
# r = int(sys.argv[1])
# url = "http://localhost:8080/{}"
async with ClientSession() as session:
data = range(r)
await io.each(lambda i: fetch(url, session), data, workers=1000, run = False)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
print("Finish")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.