Created
November 16, 2015 22:45
-
-
Save radoslawroszkowiak/da609485e0ee77cb76be to your computer and use it in GitHub Desktop.
This file contains 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
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