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

Method initialize

app/utils/guest_session_pool.py:449–466  ·  view source on GitHub ↗

初始化匿名会话池。

(self)

Source from the content-addressed store, hash-verified

447 logger.warning(f"⚠️ 匿名会话池后台维护异常: {exc}")
448
449 async def initialize(self):
450 """初始化匿名会话池。"""
451 if self._maintenance_task:
452 return
453
454 await self._ensure_capacity()
455 created = len(self._list_valid_sessions())
456
457 if created == 0:
458 fallback = await self._create_session()
459 if not self._store_session(fallback):
460 raise RuntimeError(
461 "匿名会话池初始化失败: 无法写入唯一匿名会话"
462 )
463 created = len(self._list_valid_sessions())
464
465 logger.info(f"✅ 匿名会话池初始化完成: {created} 个会话")
466 self._maintenance_task = asyncio.create_task(self._maintenance_loop())
467
468 async def close(self):
469 """关闭匿名会话池。"""

Calls 5

_ensure_capacityMethod · 0.95
_list_valid_sessionsMethod · 0.95
_create_sessionMethod · 0.95
_store_sessionMethod · 0.95
_maintenance_loopMethod · 0.95