(url: str, timeout_seconds: int)
| 207 | |
| 208 | |
| 209 | def wait_for_http(url: str, timeout_seconds: int) -> None: |
| 210 | deadline = time.time() + timeout_seconds |
| 211 | while time.time() < deadline: |
| 212 | try: |
| 213 | with urllib.request.urlopen(url, timeout=2) as response: |
| 214 | if response.status < 500: |
| 215 | return |
| 216 | except Exception: |
| 217 | time.sleep(1) |
| 218 | raise LaunchError(f"等待 Web UI 可访问超时: {url}") |
| 219 | |
| 220 | |
| 221 | def maybe_open_browser(url: str, timeout_seconds: int, enabled: bool, dry_run: bool) -> threading.Thread | None: |
no test coverage detected