Skip to content

Commit

Permalink
fix(tests): make test_get_platform less flaky (#2040)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jan 20, 2025
1 parent de05504 commit 14543c5
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import sys
import json
import time
import asyncio
import inspect
import subprocess
Expand Down Expand Up @@ -1797,10 +1798,20 @@ async def test_main() -> None:
[sys.executable, "-c", test_code],
text=True,
) as process:
try:
process.wait(2)
if process.returncode:
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
except subprocess.TimeoutExpired as e:
process.kill()
raise AssertionError("calling get_platform using asyncify resulted in a hung process") from e
timeout = 10 # seconds

start_time = time.monotonic()
while True:
return_code = process.poll()
if return_code is not None:
if return_code != 0:
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")

# success
break

if time.monotonic() - start_time > timeout:
process.kill()
raise AssertionError("calling get_platform using asyncify resulted in a hung process")

time.sleep(0.1)

0 comments on commit 14543c5

Please sign in to comment.