aiohttp benchmark
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 aioredis | |
from aiohttp import web | |
async def init(app): | |
print('redis connecton') | |
app['redis'] = await aioredis.create_redis( | |
'redis://localhost', loop=app.loop) | |
async def deinit(app): | |
print('close redis') | |
app['redis'].close() | |
await app['redis'].wait_closed() | |
async def hello(request): | |
counter = await request.app['redis'].incr('test_key') | |
return web.Response(text='{{"result": {}}}'.format(counter), | |
content_type='application/json') | |
app = web.Application() | |
app.on_startup.append(init) | |
app.on_cleanup.append(deinit) | |
app.router.add_get('/', hello) | |
web.run_app(app) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment