Skip to content

Commit d4f1878

Browse files
fix(tests): make test_get_platform less flaky (#915)
1 parent 9ea4dcd commit d4f1878

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
@@ -1739,10 +1740,20 @@ async def test_main() -> None:
17391740
[sys.executable, "-c", test_code],
17401741
text=True,
17411742
) as process:
1742-
try:
1743-
process.wait(2)
1744-
if process.returncode:
1745-
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1746-
except subprocess.TimeoutExpired as e:
1747-
process.kill()
1748-
raise AssertionError("calling get_platform using asyncify resulted in a hung process") from e
1743+
timeout = 10 # seconds
1744+
1745+
start_time = time.monotonic()
1746+
while True:
1747+
return_code = process.poll()
1748+
if return_code is not None:
1749+
if return_code != 0:
1750+
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1751+
1752+
# success
1753+
break
1754+
1755+
if time.monotonic() - start_time > timeout:
1756+
process.kill()
1757+
raise AssertionError("calling get_platform using asyncify resulted in a hung process")
1758+
1759+
time.sleep(0.1)

0 commit comments

Comments
 (0)