Skip to content

Commit f3d90af

Browse files
fix(tests): make test_get_platform less flaky (#830)
1 parent 2beaabd commit f3d90af

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

tests/test_client.py

Lines changed: 18 additions & 7 deletions
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
@@ -1830,10 +1831,20 @@ async def test_main() -> None:
18301831
[sys.executable, "-c", test_code],
18311832
text=True,
18321833
) as process:
1833-
try:
1834-
process.wait(2)
1835-
if process.returncode:
1836-
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1837-
except subprocess.TimeoutExpired as e:
1838-
process.kill()
1839-
raise AssertionError("calling get_platform using asyncify resulted in a hung process") from e
1834+
timeout = 10 # seconds
1835+
1836+
start_time = time.monotonic()
1837+
while True:
1838+
return_code = process.poll()
1839+
if return_code is not None:
1840+
if return_code != 0:
1841+
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1842+
1843+
# success
1844+
break
1845+
1846+
if time.monotonic() - start_time > timeout:
1847+
process.kill()
1848+
raise AssertionError("calling get_platform using asyncify resulted in a hung process")
1849+
1850+
time.sleep(0.1)

0 commit comments

Comments
 (0)