MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / maybe_open_browser

Function maybe_open_browser

start_webui.py:221–239  ·  view source on GitHub ↗
(url: str, timeout_seconds: int, enabled: bool, dry_run: bool)

Source from the content-addressed store, hash-verified

219
220
221def maybe_open_browser(url: str, timeout_seconds: int, enabled: bool, dry_run: bool) -> threading.Thread | None:
222 if not enabled:
223 return None
224 if dry_run:
225 log(f"[dry-run] 将在服务可访问后打开浏览器: {url}")
226 return None
227
228 def _runner() -> None:
229 try:
230 wait_for_http(url, timeout_seconds)
231 except Exception as exc:
232 log(f"浏览器自动打开前的可访问性检测失败: {exc}", "WARN")
233 return
234 webbrowser.open(url)
235 log(f"已尝试打开浏览器: {url}")
236
237 thread = threading.Thread(target=_runner, name="webui-browser", daemon=True)
238 thread.start()
239 return thread
240
241
242def launch_webui(host: str, port: int, dry_run: bool) -> int:

Callers 1

mainFunction · 0.85

Calls 2

logFunction · 0.85
startMethod · 0.45

Tested by

no test coverage detected