# HG changeset patch # User Thierry Florac # Date 1515928987 -3600 # Node ID 6d51d3409b5464b59b5a553de5f5a79691b7c28d # Parent 191d9ec5136ada8b289d0f53fdcc22c796a4b54c Updated syntax for async handlers diff -r 191d9ec5136a -r 6d51d3409b54 src/pyams_cache/handler/memcached.py --- a/src/pyams_cache/handler/memcached.py Mon Dec 11 15:26:55 2017 +0100 +++ b/src/pyams_cache/handler/memcached.py Sun Jan 14 12:23:07 2018 +0100 @@ -65,8 +65,8 @@ ip, port = server.split(':') self.client = MemcachedClient(ip, int(port)) - def get(self, key, default=None): - yield from self.client.get(key, default) + async def get(self, key, default=None): + return await self.client.get(key, default) - def set(self, key, value): - yield from self.client.set(key, value) + async def set(self, key, value): + await self.client.set(key, value) diff -r 191d9ec5136a -r 6d51d3409b54 src/pyams_cache/handler/redis.py --- a/src/pyams_cache/handler/redis.py Mon Dec 11 15:26:55 2017 +0100 +++ b/src/pyams_cache/handler/redis.py Sun Jan 14 12:23:07 2018 +0100 @@ -66,10 +66,15 @@ ip, port = server.split(':') self.connection = ip, int(port) - def get(self, key, default=None): - connection = yield from aioredis.create_connection(self.connection) - yield from connection.execute('get', key) + async def get(self, key, default=None): + connection = await aioredis.create_connection(self.connection) + value = await connection.execute('get', key) + connection.close() + await connection.wait_closed() + return value - def set(self, key, value): - connection = yield from aioredis.create_connection(self.connection) - yield from connection.execute('set', key, value) + async def set(self, key, value): + connection = await aioredis.create_connection(self.connection) + await connection.execute('set', key, value) + connection.close() + await connection.wait_closed()