Skip to content

Commit 51968d4

Browse files
fix(tests): make test_get_platform less flaky
1 parent 5d59373 commit 51968d4

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

Diff for: 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
@@ -1539,10 +1540,20 @@ async def test_main() -> None:
15391540
[sys.executable, "-c", test_code],
15401541
text=True,
15411542
) as process:
1542-
try:
1543-
process.wait(2)
1544-
if process.returncode:
1545-
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1546-
except subprocess.TimeoutExpired as e:
1547-
process.kill()
1548-
raise AssertionError("calling get_platform using asyncify resulted in a hung process") from e
1543+
timeout = 10 # seconds
1544+
1545+
start_time = time.monotonic()
1546+
while True:
1547+
return_code = process.poll()
1548+
if return_code is not None:
1549+
if return_code != 0:
1550+
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1551+
1552+
# success
1553+
break
1554+
1555+
if time.monotonic() - start_time > timeout:
1556+
process.kill()
1557+
raise AssertionError("calling get_platform using asyncify resulted in a hung process")
1558+
1559+
time.sleep(0.1)

0 commit comments

Comments
 (0)