Skip to content

Commit 4cd4c58

Browse files
committed
test: widen LOOPBACK_FIND_TIMEOUT under PyPy
The 75ms loopback budget for ZeroconfServiceTypes.find() races PyPy's JIT warmup the first time the path runs early in the suite. Two back-to-back runs on master flaked at the same 21% point: one on test_integration_with_listener and one on test_integration_with_listener_v6_records. Bump the timeout to 300ms on PyPy only; CPython keeps the existing 75ms budget.
1 parent 93c3112 commit 4cd4c58

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tests/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from __future__ import annotations
2424

2525
import asyncio
26+
import platform
2627
import socket
2728
import time
2829
from functools import cache
@@ -35,6 +36,8 @@
3536

3637
_MONOTONIC_RESOLUTION = time.get_clock_info("monotonic").resolution
3738

39+
_IS_PYPY = platform.python_implementation() == "PyPy"
40+
3841
# get_service_info / async_request timeout for tests using the
3942
# `quick_request_timing` fixture. The fixture cuts the initial-query
4043
# delay to ~15ms (10ms _LISTENER_TIME + 1-5ms jitter), so 50ms is
@@ -49,7 +52,9 @@
4952
# the `quick_timing` fixture, which shrinks the browser's first-query
5053
# delay from RFC 6762 §5.2's 20-120ms window to 1-5ms; with that shave
5154
# the registrar's response lands inside ~10ms and 75ms is ~7x headroom.
52-
LOOPBACK_FIND_TIMEOUT = 0.075
55+
# PyPy's JIT is still warming up the first time this path runs early in
56+
# the suite, so the round trip is too slow for 75ms; give it more room.
57+
LOOPBACK_FIND_TIMEOUT = 0.3 if _IS_PYPY else 0.075
5358

5459
# IPv6-only `find()` on Linux GitHub runners can hit `[Errno 101] Network
5560
# is unreachable` on the `::1` socket and falls back to the `fe80::` link-

0 commit comments

Comments
 (0)