MCPcopy Create free account
hub / github.com/CJackHwang/AIstudioProxyAPI / input_with_timeout

Function input_with_timeout

launch_camoufox.py:594–618  ·  view source on GitHub ↗
(prompt_message: str, timeout_seconds: int = 30)

Source from the content-addressed store, hash-verified

592
593# --- Input function with timeout (from dev - more robust Windows implementation) ---
594def input_with_timeout(prompt_message: str, timeout_seconds: int = 30) -> str:
595 print(prompt_message, end="", flush=True)
596 if sys.platform == "win32":
597 user_input_container = [None]
598
599 def get_input_in_thread():
600 try:
601 user_input_container[0] = sys.stdin.readline().strip()
602 except Exception:
603 user_input_container[0] = "" # Return empty string on error
604
605 input_thread = threading.Thread(target=get_input_in_thread, daemon=True)
606 input_thread.start()
607 input_thread.join(timeout=timeout_seconds)
608 if input_thread.is_alive():
609 print("\nInput timed out. Using default value.", flush=True)
610 return ""
611 return user_input_container[0] if user_input_container[0] is not None else ""
612 else: # Linux/macOS
613 readable_fds, _, _ = select.select([sys.stdin], [], [], timeout_seconds)
614 if readable_fds:
615 return sys.stdin.readline().strip()
616 else:
617 print("\nInput timed out. Using default value.", flush=True)
618 return ""
619
620
621def get_proxy_from_gsettings():

Callers 1

launch_camoufox.pyFile · 0.70

Calls 2

selectMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected