Andrew Svetlov
http://asvetlov.blogspot.com
andrew.svetlov@gmail.com
http://asvetlov.github.io/aiohttp-krasnoyarsk-2016/
async def handler(request):
value1 = await get_part1(request)
value2 = await get_part2(request)
return render_response(value1, value2)
async def handler(request):
value1, value2 = await asyncio.gather(get_part1(request),
get_part2(request),
loop=request.app.loop)
return render_response(value1, value2)
async def handler(request):
value1, value2 = await asyncio.gather(get_part1(request),
get_part2(request),
loop=request.app.loop)
return render_response(value1, value2)
async def handler(request):
value1 = await get_part1(request)
value2 = await get_part2(request)
return render_response(value1, value2)
async def handler(request):
session = request.app['client_session']
async with session.get(url) as resp:
body = yield from resp.json()
return render_json(body)
async def handler(request):
async with request.app['db'] as conn:
await conn.execute('SELECT * FROM ...')
with asyncio_timeout.timeout(10):
async with session.get(url) as response:
assert response.status == 200
return await response.read()
Think about github.com, facebook.com or google.com
Hosted in sibling docker contatiner
Andrew Svetlov
http://asvetlov.blogspot.com
andrew.svetlov@gmail.com
http://asvetlov.github.io/aiohttp-krasnoyarsk-2016/