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

Method reset

api_utils/server_state.py:48–97  ·  view source on GitHub ↗

Reset all state to initial values. Useful for testing.

(self)

Source from the content-addressed store, hash-verified

46 self.reset()
47
48 def reset(self) -> None:
49 """Reset all state to initial values. Useful for testing."""
50 # --- Stream Queue ---
51 self.STREAM_QUEUE: Optional[multiprocessing.Queue] = None
52 self.STREAM_PROCESS: Optional[multiprocessing.Process] = None
53
54 # --- Playwright/Browser State ---
55 self.playwright_manager: Optional["AsyncPlaywright"] = None
56 self.browser_instance: Optional["AsyncBrowser"] = None
57 self.page_instance: Optional["AsyncPage"] = None
58 self.is_playwright_ready: bool = False
59 self.is_browser_connected: bool = False
60 self.is_page_ready: bool = False
61 self.is_initializing: bool = False
62
63 # --- Proxy Configuration ---
64 self.PLAYWRIGHT_PROXY_SETTINGS: Optional[Dict[str, str]] = None
65
66 # --- Model State ---
67 self.global_model_list_raw_json: Optional[str] = None
68 self.parsed_model_list: List[Dict[str, Any]] = []
69 self.model_list_fetch_event: Event = asyncio.Event()
70 self.current_ai_studio_model_id: Optional[str] = None
71 self.current_auth_profile_path: Optional[str] = None
72 self.model_switching_lock: Lock = Lock()
73 self.excluded_model_ids: Set[str] = set()
74
75 # --- Request Processing State ---
76 self.request_queue: "Optional[Queue[QueueItem]]" = None
77 self.processing_lock: Optional[Lock] = None
78 self.worker_task: "Optional[Task[None]]" = None
79
80 # --- Parameter Cache ---
81 self.page_params_cache: Dict[str, Any] = {}
82 self.params_cache_lock: Lock = Lock()
83
84 # --- Debug Logging State ---
85 self.console_logs: List[Dict[str, Any]] = []
86 self.network_log: Dict[str, List[Dict[str, Any]]] = {
87 "requests": [],
88 "responses": [],
89 }
90
91 # --- Logging ---
92 self.logger: logging.Logger = logging.getLogger("AIStudioProxyServer")
93 self.log_ws_manager: Optional["WebSocketConnectionManager"] = None
94
95 # --- Control Flags ---
96 self.should_exit: bool = False
97 self.quota_watchdog: Optional[Callable] = None
98
99 def clear_debug_logs(self) -> None:
100 """Clear console and network logs (called after each request)."""

Callers 15

fresh_stateFunction · 0.95
__init__Method · 0.95
log_contextFunction · 0.80
request_contextFunction · 0.80
reset_global_stateFunction · 0.80
real_locks_mock_browserFunction · 0.80
real_server_stateFunction · 0.80
clean_contextMethod · 0.80

Calls

no outgoing calls