| 42 | self._video_pending[token_id] = max(0, int(self._video_pending.get(token_id, 0))) + 1 |
| 43 | |
| 44 | async def release_pending(self, token_id: int, for_image_generation: bool = False, for_video_generation: bool = False): |
| 45 | async with self._pending_lock: |
| 46 | if for_image_generation: |
| 47 | current = max(0, int(self._image_pending.get(token_id, 0))) |
| 48 | if current <= 1: |
| 49 | self._image_pending.pop(token_id, None) |
| 50 | else: |
| 51 | self._image_pending[token_id] = current - 1 |
| 52 | elif for_video_generation: |
| 53 | current = max(0, int(self._video_pending.get(token_id, 0))) |
| 54 | if current <= 1: |
| 55 | self._video_pending.pop(token_id, None) |
| 56 | else: |
| 57 | self._video_pending[token_id] = current - 1 |
| 58 | |
| 59 | async def _get_token_load(self, token_id: int, for_image_generation: bool, for_video_generation: bool) -> tuple[int, Optional[int]]: |
| 60 | """获取 token 当前负载。 |