fix(status): use ms timeout for ping on macOS
ping(8) -W flag is milliseconds on macOS, seconds on Linux. Code used -W 1 for both, giving macOS a 1ms timeout that fails any host with RTT >1ms (typical wifi/mesh is 2-10ms). Use -W 1000 on darwin to match the intended 1s timeout. Add regression test asserting the platform-specific value.
This commit is contained in:
@@ -60,8 +60,14 @@ async def check_node(check_method: str, target: str | None, ip: str | None) -> d
|
||||
|
||||
|
||||
async def _ping(host: str) -> bool:
|
||||
# ping(8) -W flag units differ by OS:
|
||||
# Linux: seconds (-W 1 = 1s)
|
||||
# macOS: milliseconds (-W 1 = 1ms — fails for any RTT >1ms)
|
||||
# Windows: -w in ms (-w 1000 = 1s)
|
||||
if sys.platform == "win32":
|
||||
args = ["ping", "-n", "1", "-w", "1000", host]
|
||||
elif sys.platform == "darwin":
|
||||
args = ["ping", "-c", "1", "-W", "1000", host]
|
||||
else:
|
||||
args = ["ping", "-c", "1", "-W", "1", host]
|
||||
proc = await asyncio.create_subprocess_exec(
|
||||
|
||||
Reference in New Issue
Block a user