Skip to content

Commit 6e9208d

Browse files
fix(tests): make test_get_platform less flaky (#26)
1 parent e252de7 commit 6e9208d

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
@@ -1565,10 +1566,20 @@ async def test_main() -> None:
15651566
[sys.executable, "-c", test_code],
15661567
text=True,
15671568
) as process:
1568-
try:
1569-
process.wait(2)
1570-
if process.returncode:
1571-
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1572-
except subprocess.TimeoutExpired as e:
1573-
process.kill()
1574-
raise AssertionError("calling get_platform using asyncify resulted in a hung process") from e
1569+
timeout = 10 # seconds
1570+
1571+
start_time = time.monotonic()
1572+
while True:
1573+
return_code = process.poll()
1574+
if return_code is not None:
1575+
if return_code != 0:
1576+
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1577+
1578+
# success
1579+
break
1580+
1581+
if time.monotonic() - start_time > timeout:
1582+
process.kill()
1583+
raise AssertionError("calling get_platform using asyncify resulted in a hung process")
1584+
1585+
time.sleep(0.1)

0 commit comments

Comments
 (0)