Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import asyncio
import json
import time
import aiohttp
result = []
async def download_site(session, url):
async with session.get(url) as response:
resp_json = await response.json()
print("url", url, resp_json)
async def download_all_sites(_sites):
async with aiohttp.ClientSession() as session:
tasks = []
for url in _sites:
task = asyncio.ensure_future(download_site(session, url))
await asyncio.gather(*tasks, return_exceptions=True)
if __name__ == "__main__":
sites = [
start_time = time.time()
# print(result)
print("total time took is %s" % (time.time() - start_time))
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.