Skip to content

Commit d59865b

Browse files
fix(tests): make test_get_platform less flaky (#52)
1 parent 1c68af1 commit d59865b

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
@@ -1645,10 +1646,20 @@ async def test_main() -> None:
16451646
[sys.executable, "-c", test_code],
16461647
text=True,
16471648
) as process:
1648-
try:
1649-
process.wait(2)
1650-
if process.returncode:
1651-
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1652-
except subprocess.TimeoutExpired as e:
1653-
process.kill()
1654-
raise AssertionError("calling get_platform using asyncify resulted in a hung process") from e
1649+
timeout = 10 # seconds
1650+
1651+
start_time = time.monotonic()
1652+
while True:
1653+
return_code = process.poll()
1654+
if return_code is not None:
1655+
if return_code != 0:
1656+
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1657+
1658+
# success
1659+
break
1660+
1661+
if time.monotonic() - start_time > timeout:
1662+
process.kill()
1663+
raise AssertionError("calling get_platform using asyncify resulted in a hung process")
1664+
1665+
time.sleep(0.1)

0 commit comments

Comments
 (0)