import aiohttp
import time
import asyncio


async def download_site(session, url):
    async with session.get(url) as response:
        print(f"Read {response.content_length} from {url}")


async def download_all_sites(sites):
    async with aiohttp.ClientSession() as session:
        tasks = []
        for url in sites:
            task = asyncio.create_task(download_site(session, url))
            tasks.append(task)
        await asyncio.gather(*tasks)


if __name__ == "__main__":
    sites = [
                "https://homepage.sch.ac.kr",
                "https://www.google.co.kr",
            ] * 80
    start_time = time.time()
    asyncio.get_event_loop().run_until_complete(download_all_sites(sites))
    duration = time.time() - start_time
    print(f'Download {len(sites)} in {duration} seconds')
