Created
September 20, 2018 14:18
-
-
Save cgarciae/4d35bb9f79c6e72533f26abbaeb17fb2 to your computer and use it in GitHub Desktop.
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
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