Skip to content

Commit 72ea05c

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
fix(tests): make test_get_platform less flaky (#2040)
1 parent 9b8eab9 commit 72ea05c

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
@@ -1797,10 +1798,20 @@ async def test_main() -> None:
17971798
[sys.executable, "-c", test_code],
17981799
text=True,
17991800
) as process:
1800-
try:
1801-
process.wait(2)
1802-
if process.returncode:
1803-
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1804-
except subprocess.TimeoutExpired as e:
1805-
process.kill()
1806-
raise AssertionError("calling get_platform using asyncify resulted in a hung process") from e
1801+
timeout = 10 # seconds
1802+
1803+
start_time = time.monotonic()
1804+
while True:
1805+
return_code = process.poll()
1806+
if return_code is not None:
1807+
if return_code != 0:
1808+
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1809+
1810+
# success
1811+
break
1812+
1813+
if time.monotonic() - start_time > timeout:
1814+
process.kill()
1815+
raise AssertionError("calling get_platform using asyncify resulted in a hung process")
1816+
1817+
time.sleep(0.1)

0 commit comments

Comments
 (0)