Skip to content

Commit 75bf47a

Browse files
committed
Try to fix test flakiness
1 parent e9edfbc commit 75bf47a

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

tests/nexus/test_worker.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,23 @@ async def op(
7676
for i in range(num_nexus_operations)
7777
]
7878

79-
# Poll
80-
for _ in range(50): # 5 seconds max
81-
if len(ids) >= expected_num_executed:
79+
# Allow 3s for expected operations to start
80+
deadline = asyncio.get_event_loop().time() + 3.0
81+
while len(ids) < expected_num_executed:
82+
if asyncio.get_event_loop().time() > deadline:
8283
break
83-
await asyncio.sleep(0.1)
84+
await asyncio.sleep(0.05)
8485

8586
# No more should arrive
86-
await asyncio.sleep(0.2)
87-
assert len(ids) == expected_num_executed
88-
assert len(set(ids)) == len(ids)
87+
await asyncio.sleep(0.1)
8988

9089
event.set()
90+
91+
assert (
92+
len(ids) == expected_num_executed
93+
), f"Expected {expected_num_executed} operations, got {len(ids)}"
94+
assert len(set(ids)) == len(ids), "Duplicate operation IDs detected"
95+
9196
for task in tasks:
9297
if not task.done():
9398
task.cancel()

0 commit comments

Comments
 (0)