MCPcopy Create free account
hub / github.com/TheSmallHanCat/flow2api / _get_token_lock

Method _get_token_lock

src/services/token_manager.py:29–41  ·  view source on GitHub ↗

按 token 维度获取锁,避免不同 token 之间串行阻塞。

(
        self,
        lock_map: dict[int, asyncio.Lock],
        guard: asyncio.Lock,
        token_id: int,
    )

Source from the content-addressed store, hash-verified

27 self._protocol_refresher_task: Optional[asyncio.Task] = None
28
29 async def _get_token_lock(
30 self,
31 lock_map: dict[int, asyncio.Lock],
32 guard: asyncio.Lock,
33 token_id: int,
34 ) -> asyncio.Lock:
35 """按 token 维度获取锁,避免不同 token 之间串行阻塞。"""
36 async with guard:
37 lock = lock_map.get(token_id)
38 if lock is None:
39 lock = asyncio.Lock()
40 lock_map[token_id] = lock
41 return lock
42
43 def _get_project_pool_size(self) -> int:
44 """读取当前生效的单 Token 项目池大小配置。"""

Callers 3

_refresh_at_innerMethod · 0.95
ensure_project_existsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected