Skip to content

Commit 4367005

Browse files
fix(tests): make test_get_platform less flaky (#500)
1 parent 0fb6642 commit 4367005

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
@@ -1721,10 +1722,20 @@ async def test_main() -> None:
17211722
[sys.executable, "-c", test_code],
17221723
text=True,
17231724
) as process:
1724-
try:
1725-
process.wait(2)
1726-
if process.returncode:
1727-
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1728-
except subprocess.TimeoutExpired as e:
1729-
process.kill()
1730-
raise AssertionError("calling get_platform using asyncify resulted in a hung process") from e
1725+
timeout = 10 # seconds
1726+
1727+
start_time = time.monotonic()
1728+
while True:
1729+
return_code = process.poll()
1730+
if return_code is not None:
1731+
if return_code != 0:
1732+
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1733+
1734+
# success
1735+
break
1736+
1737+
if time.monotonic() - start_time > timeout:
1738+
process.kill()
1739+
raise AssertionError("calling get_platform using asyncify resulted in a hung process")
1740+
1741+
time.sleep(0.1)

0 commit comments

Comments
 (0)