问题描述
Unit Tests 工作流的 macos-latest lane 因 tests/test_kb_rate_limiter.py:34 的一条计时断言失败,同一 commit 在 ubuntu-latest 上通过,套件其余部分全绿(1 failed, 3631 passed, 5 skipped)。
tests/test_kb_rate_limiter.py::test_concurrent_waiters_keep_the_configured_interval[0]
E AssertionError: [0.12367229100004806, 0.08920287499995538, 0.10840137500002811, 0.10127545899996448, 0.1012895410000283]
E assert 0.08920287499995538 >= 0.09
RateLimiter(600) 的调用间隔为 60 / 600 = 0.1 s,测试给了 10% 容差(min(gaps) >= 0.09);实测最小间隔 0.08920 s,比容差低了 0.8 ms。
如何复现?
https://github.com/AstrBotDevs/AstrBot/actions/runs/36587137473/job/109470342854?pr=8169
错误日志
___________________________ test_concurrent_waiters_keep_the_configured_interval[0] ___________________________
event_loop_stall = 0
@pytest.mark.asyncio
@pytest.mark.parametrize("event_loop_stall", [0, 0.4])
async def test_concurrent_waiters_keep_the_configured_interval(event_loop_stall):
limiter = RateLimiter(600) # 0.1 s between calls
...
times.sort()
gaps = [b - a for a, b in zip(times, times[1:])]
assert len(gaps) == 5
# Every pair of consecutive calls must be at least the interval apart
# (small tolerance for timer granularity).
> assert min(gaps) >= 0.09, gaps
E AssertionError: [0.12367229100004806, 0.08920287499995538, 0.10840137500002811, 0.10127545899996448, 0.1012895410000283]
E assert 0.08920287499995538 >= 0.09
E + where 0.08920287499995538 = min([0.12367229100004806, 0.08920287499995538, 0.10840137500002811, 0.10127545899996448, 0.1012895410000283])
tests/test_kb_rate_limiter.py:34: AssertionError
============================= 1 failed, 3631 passed, 5 skipped, 36 warnings in 257.55s (0:04:17) =============================
检查清单
问题描述
Unit Tests工作流的macos-latestlane 因tests/test_kb_rate_limiter.py:34的一条计时断言失败,同一 commit 在ubuntu-latest上通过,套件其余部分全绿(1 failed, 3631 passed, 5 skipped)。RateLimiter(600)的调用间隔为60 / 600 = 0.1 s,测试给了 10% 容差(min(gaps) >= 0.09);实测最小间隔0.08920 s,比容差低了 0.8 ms。如何复现?
https://github.com/AstrBotDevs/AstrBot/actions/runs/36587137473/job/109470342854?pr=8169
错误日志
检查清单