MCPcopy Create free account
hub / github.com/ZyphrZero/z.ai2api_python / GuestSession

Class GuestSession

app/utils/guest_session_pool.py:155–184  ·  view source on GitHub ↗

单个匿名访客会话。

Source from the content-addressed store, hash-verified

153
154@dataclass
155class GuestSession:
156 """单个匿名访客会话。"""
157
158 token: str
159 user_id: str
160 username: str
161 created_at: float = field(default_factory=time.time)
162 expires_at: float = field(default_factory=_build_session_expiry)
163 active_requests: int = 0
164 valid: bool = True
165 failure_count: int = 0
166 last_failure_time: float = 0.0
167
168 @property
169 def age(self) -> float:
170 """会话存活时间。"""
171 return time.time() - self.created_at
172
173 @property
174 def is_expired(self) -> bool:
175 """判断会话是否已过期。"""
176 return time.time() >= self.expires_at
177
178 def snapshot(self) -> Dict[str, str]:
179 """获取当前会话快照。"""
180 return {
181 "token": self.token,
182 "user_id": self.user_id,
183 "username": self.username,
184 }
185
186
187class GuestSessionPool:

Callers 4

_make_sessionFunction · 0.90
_make_sessionFunction · 0.90
_make_guest_sessionFunction · 0.90
_create_sessionMethod · 0.85

Calls

no outgoing calls

Tested by 3

_make_sessionFunction · 0.72
_make_sessionFunction · 0.72
_make_guest_sessionFunction · 0.72