Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import asyncio, aioredis
async def main():
pool = await aioredis.create_redis_pool('localhost',
db=0, password=None, ssl=False, minsize=4, maxsize=10, encoding='utf8')
# Assuming we're not the only ones using the pool
start_other_coroutines_that_use_redis(pool)
# This time we do a transaction
tr = pool.multi_exec()
tr.set("key", "hello")
# `execute` must be awaited, and be careful,
# awaiting the set command would deadlock the program
# as you would never be able to commit the transaction!
await tr.execute()
if __name__ == '__main__':
loop = asyncio.main_loop()
loop.run_until_complete(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment