Skip to content

Commit 9ad9881

Browse files
fix(tests): make test_get_platform less flaky (#95)
1 parent d093719 commit 9ad9881

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

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
@@ -1632,10 +1633,20 @@ async def test_main() -> None:
16321633
[sys.executable, "-c", test_code],
16331634
text=True,
16341635
) as process:
1635-
try:
1636-
process.wait(2)
1637-
if process.returncode:
1638-
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1639-
except subprocess.TimeoutExpired as e:
1640-
process.kill()
1641-
raise AssertionError("calling get_platform using asyncify resulted in a hung process") from e
1636+
timeout = 10 # seconds
1637+
1638+
start_time = time.monotonic()
1639+
while True:
1640+
return_code = process.poll()
1641+
if return_code is not None:
1642+
if return_code != 0:
1643+
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1644+
1645+
# success
1646+
break
1647+
1648+
if time.monotonic() - start_time > timeout:
1649+
process.kill()
1650+
raise AssertionError("calling get_platform using asyncify resulted in a hung process")
1651+
1652+
time.sleep(0.1)

0 commit comments

Comments
 (0)