From 3db60170aacc97a543f568f5473d419fec2b6fb0 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Fri, 30 Jan 2026 17:17:50 +0100 Subject: [PATCH] Fix flaky test_group_throttle_rate_limit race condition (#6504) The test was failing intermittently in CI because concurrent async operations in asyncio.gather() were getting slightly different timestamps (microseconds apart) despite being inside a time_machine context. When test2.execute() calls were timestamped at start+2ms due to async scheduling delays, they weren't cleaned up in the final test block (cutoff = start+1ms), causing a false rate limit error. Fix by using tick=False to completely freeze time during the gather, ensuring all 4 calls get the exact same timestamp. Co-authored-by: Claude Sonnet 4.5 --- tests/jobs/test_job_decorator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/jobs/test_job_decorator.py b/tests/jobs/test_job_decorator.py index 3cce977ec..aa5396789 100644 --- a/tests/jobs/test_job_decorator.py +++ b/tests/jobs/test_job_decorator.py @@ -941,7 +941,7 @@ async def test_group_throttle_rate_limit(coresys: CoreSys, error: JobException | start = utcnow() - with time_machine.travel(start): + with time_machine.travel(start, tick=False): await asyncio.gather( *[test1.execute(), test1.execute(), test2.execute(), test2.execute()] )