按 token 维度获取锁,避免不同 token 之间串行阻塞。
(
self,
lock_map: dict[int, asyncio.Lock],
guard: asyncio.Lock,
token_id: int,
)
| 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 项目池大小配置。""" |
no outgoing calls
no test coverage detected