(http_port: int, admin_password: str)
| 455 | |
| 456 | |
| 457 | def wait_console_ready(http_port: int, admin_password: str) -> None: |
| 458 | info("Waiting for console to become ready...") |
| 459 | url = f"http://127.0.0.1:{http_port}/api/v1/console/session" |
| 460 | deadline = time.monotonic() + CONSOLE_READY_TIMEOUT |
| 461 | while time.monotonic() < deadline: |
| 462 | try: |
| 463 | req = urllib.request.Request(url) |
| 464 | with urllib.request.urlopen(req, timeout=5): |
| 465 | pass |
| 466 | _print_console_ready(http_port, admin_password) |
| 467 | return |
| 468 | except urllib.error.HTTPError: |
| 469 | _print_console_ready(http_port, admin_password) |
| 470 | return |
| 471 | except (urllib.error.URLError, OSError): |
| 472 | time.sleep(POLL_INTERVAL) |
| 473 | |
| 474 | fatal("console", f"Console did not become ready within {CONSOLE_READY_TIMEOUT}s.") |
| 475 | |
| 476 | |
| 477 | def _print_console_ready(http_port: int, admin_password: str) -> None: |
no test coverage detected