Skip to content

Commit

Permalink
Poll for completion up to 1000 times, refs #50
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Apr 27, 2024
1 parent 18e98f8 commit 8bc91cd
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests/test_enrichments.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,13 @@ async def increment():
loop = asyncio.get_event_loop()
for i in range(100):
loop.create_task(increment())
# Wait 1s
await asyncio.sleep(1)
# Check the counter
counter = await db.execute("select n from counter where id = 1")
assert counter.first()[0] == 1000
# Check counter every 0.1s until it reaches 1000
num_loops = 0
while True:
num_loops += 1
await asyncio.sleep(0.1)
counter = await db.execute("select n from counter where id = 1")
if counter.first()[0] == 1000:
break
assert num_loops < 1000, "Counter did not reach goal after 1000 checks"

0 comments on commit 8bc91cd

Please sign in to comment.