1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2026-02-14 23:19:37 +00:00

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 <noreply@anthropic.com>
This commit is contained in:
Stefan Agner
2026-01-30 17:17:50 +01:00
committed by GitHub
parent a5c3781f9d
commit 3db60170aa

View File

@@ -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()]
)