Asynchronous HTTP requests in Python 3.5

Just a snippet with aiohttp.

import aiohttp
import asyncio

async def get_status(url, id):
    r = await aiohttp.get(url)
    print(r.status, id)
    r.close()


tasks = []
for i in range(100):
    tasks.append(asyncio.ensure_future(get_status('https://api.github.com/events', id=i)))


if...
  2015-11-09   2768   Loadingpythonasyncio  Read More