Skip to content

Commit 95d5105

Browse files
authored
chore: Fix flaky test_allows_multiple_run_calls (#1573)
### Description - Fix flaky `test_allows_multiple_run_calls` ### Testing - Local stress testing ### Checklist - [ ] CI passed
1 parent 2129027 commit 95d5105

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

tests/unit/_autoscaling/test_autoscaled_pool.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,14 +310,14 @@ async def test_allows_multiple_run_calls(system_status: SystemStatus | Mock) ->
310310
done_count = 0
311311

312312
async def run() -> None:
313-
await asyncio.sleep(0.1)
314313
nonlocal done_count
315314
done_count += 1
315+
await asyncio.sleep(0.1)
316316

317317
pool = AutoscaledPool(
318318
system_status=system_status,
319319
run_task_function=run,
320-
is_task_ready_function=lambda: future(True),
320+
is_task_ready_function=lambda: future(done_count < 4),
321321
is_finished_function=lambda: future(done_count >= 4),
322322
concurrency_settings=ConcurrencySettings(
323323
min_concurrency=4,
@@ -330,8 +330,6 @@ async def run() -> None:
330330
assert done_count == 4
331331

332332
done_count = 0
333-
await asyncio.sleep(0.2) # Allow any lingering callbacks to complete
334-
done_count = 0 # Reset again to ensure clean state
335333

336334
await pool.run()
337335
assert done_count == 4

0 commit comments

Comments
 (0)