Skip to content

Commit 1eebaeb

Browse files
fix(tests): make test_get_platform less flaky (#500)
1 parent 27ae2b2 commit 1eebaeb

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

tests/test_client.py

+18-7
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
@@ -1711,10 +1712,20 @@ async def test_main() -> None:
17111712
[sys.executable, "-c", test_code],
17121713
text=True,
17131714
) as process:
1714-
try:
1715-
process.wait(2)
1716-
if process.returncode:
1717-
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1718-
except subprocess.TimeoutExpired as e:
1719-
process.kill()
1720-
raise AssertionError("calling get_platform using asyncify resulted in a hung process") from e
1715+
timeout = 10 # seconds
1716+
1717+
start_time = time.monotonic()
1718+
while True:
1719+
return_code = process.poll()
1720+
if return_code is not None:
1721+
if return_code != 0:
1722+
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1723+
1724+
# success
1725+
break
1726+
1727+
if time.monotonic() - start_time > timeout:
1728+
process.kill()
1729+
raise AssertionError("calling get_platform using asyncify resulted in a hung process")
1730+
1731+
time.sleep(0.1)

0 commit comments

Comments
 (0)