Skip to content

Commit 2dff4e0

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
fix(tests): make test_get_platform less flaky (#675)
1 parent 9bc6a5e commit 2dff4e0

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
@@ -1896,10 +1897,20 @@ async def test_main() -> None:
18961897
[sys.executable, "-c", test_code],
18971898
text=True,
18981899
) as process:
1899-
try:
1900-
process.wait(2)
1901-
if process.returncode:
1902-
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1903-
except subprocess.TimeoutExpired as e:
1904-
process.kill()
1905-
raise AssertionError("calling get_platform using asyncify resulted in a hung process") from e
1900+
timeout = 10 # seconds
1901+
1902+
start_time = time.monotonic()
1903+
while True:
1904+
return_code = process.poll()
1905+
if return_code is not None:
1906+
if return_code != 0:
1907+
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1908+
1909+
# success
1910+
break
1911+
1912+
if time.monotonic() - start_time > timeout:
1913+
process.kill()
1914+
raise AssertionError("calling get_platform using asyncify resulted in a hung process")
1915+
1916+
time.sleep(0.1)

0 commit comments

Comments
 (0)