Skip to content

Instantly share code, notes, and snippets.

@kristoff-it
Last active September 18, 2019 13:42
Show Gist options
  • Save kristoff-it/eeb4c9531962927e1915e45799292ac5 to your computer and use it in GitHub Desktop.
Save kristoff-it/eeb4c9531962927e1915e45799292ac5 to your computer and use it in GitHub Desktop.
last_id = '$'
while True:
events = await pool.xread(['wins_stream'], latest_ids=[last_id], timeout=0, count=10)
tasks = []
for _, e_id, e in events:
winner = e['winner']
tasks.append(add_new_win(pool, winner))
last_id = e_id
await asyncio.gather(*tasks)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment