Skip to content

Commit 6b6b36c

Browse files
fix(tests): make test_get_platform less flaky (#576)
1 parent ae1b97a commit 6b6b36c

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

tests/test_client.py

+18-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
import sys
88
import json
9+
import time
910
import asyncio
1011
import inspect
1112
import subprocess
@@ -1869,10 +1870,20 @@ async def test_main() -> None:
18691870
[sys.executable, "-c", test_code],
18701871
text=True,
18711872
) as process:
1872-
try:
1873-
process.wait(2)
1874-
if process.returncode:
1875-
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1876-
except subprocess.TimeoutExpired as e:
1877-
process.kill()
1878-
raise AssertionError("calling get_platform using asyncify resulted in a hung process") from e
1873+
timeout = 10 # seconds
1874+
1875+
start_time = time.monotonic()
1876+
while True:
1877+
return_code = process.poll()
1878+
if return_code is not None:
1879+
if return_code != 0:
1880+
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1881+
1882+
# success
1883+
break
1884+
1885+
if time.monotonic() - start_time > timeout:
1886+
process.kill()
1887+
raise AssertionError("calling get_platform using asyncify resulted in a hung process")
1888+
1889+
time.sleep(0.1)

0 commit comments

Comments
 (0)