|
16 | 16 | <...>
|
17 | 17 | Tracing '/**/src/<package>/__init__.py'
|
18 | 18 | """
|
| 19 | + |
19 | 20 | from __future__ import annotations
|
20 | 21 |
|
21 | 22 | import errno
|
@@ -315,12 +316,7 @@ def _start_container() -> None:
|
315 | 316 | try:
|
316 | 317 | subprocess.run(cmd, check=True, capture_output=True, shell=True, text=True)
|
317 | 318 | except subprocess.CalledProcessError as exc:
|
318 |
| - err = ( |
319 |
| - f"Failed to start container:\n" |
320 |
| - f"cmd: {cmd}\n" |
321 |
| - f"stdout: {exc.stdout}\n" |
322 |
| - f"stderr: {exc.stderr}" |
323 |
| - ) |
| 319 | + err = f"Failed to start container:\ncmd: {cmd}\nstdout: {exc.stdout}\nstderr: {exc.stderr}" |
324 | 320 | pytest.fail(err)
|
325 | 321 |
|
326 | 322 | # image is local, can't be pulled, use default
|
@@ -419,17 +415,24 @@ def _start_server() -> None:
|
419 | 415 | env=os.environ,
|
420 | 416 | )
|
421 | 417 | tries = 0
|
422 |
| - max_tries = 10 |
| 418 | + timeout = 2 |
| 419 | + max_tries = 15 # GHA macos runner showed occasional failures with 10s |
| 420 | + msg = "Could not start the server." |
423 | 421 | while tries < max_tries:
|
424 | 422 | try:
|
425 |
| - res = requests.get("http://localhost:8000", timeout=1) |
| 423 | + # timeout increased to 2s due to observed GHA macos failures |
| 424 | + res = requests.get("http://localhost:8000", timeout=timeout) |
426 | 425 | if res.status_code == requests.codes.get("not_found"):
|
427 | 426 | return
|
428 |
| - except requests.exceptions.ConnectionError: # noqa: PERF203 |
| 427 | + except (requests.exceptions.ConnectionError, requests.RequestException): # noqa: PERF203 |
429 | 428 | tries += 1
|
430 | 429 | time.sleep(1)
|
431 |
| - |
432 |
| - msg = "Could not start the server." |
| 430 | + INFRASTRUCTURE.proc.terminate() |
| 431 | + stdout, stderr = INFRASTRUCTURE.proc.communicate() |
| 432 | + msg += ( |
| 433 | + f"Could not start the server after {tries} tries with a timeout of {timeout} seconds each." |
| 434 | + f" Server stdout:\n{stdout.decode()}\nServer stderr:\n{stderr.decode()}" |
| 435 | + ) |
433 | 436 | raise RuntimeError(msg)
|
434 | 437 |
|
435 | 438 |
|
|
0 commit comments