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)
# We reserve a connection for a blocking operation
with await pool as conn:
items = await conn.xread(['stream'], latest_ids=['$'], timeout=0)
await process_items(items)
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