Skip to content

Instantly share code, notes, and snippets.

@radoslawroszkowiak
Created November 16, 2015 22:45
Show Gist options
  • Save radoslawroszkowiak/da609485e0ee77cb76be to your computer and use it in GitHub Desktop.
Save radoslawroszkowiak/da609485e0ee77cb76be to your computer and use it in GitHub Desktop.
import asyncio
import aiohttp
async def get_content(url):
response = await aiohttp.request('GET', url)
body = await response.read()
return body
async def main():
urls = ['http://google.pl'] * 200
tasks = []
for url in urls:
tasks.append(get_content(url))
results = []
for body in await asyncio.gather(*tasks):
results.append(body)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment