Initialize all clients in the pool.
(self)
| 34 | self._restart_locks[c.id] = asyncio.Lock() |
| 35 | |
| 36 | async def init(self) -> None: |
| 37 | """Initialize all clients in the pool.""" |
| 38 | success_count = 0 |
| 39 | for client in self._clients: |
| 40 | if not client.running(): |
| 41 | try: |
| 42 | await client.init( |
| 43 | timeout=g_config.gemini.timeout, |
| 44 | watchdog_timeout=g_config.gemini.watchdog_timeout, |
| 45 | auto_refresh=g_config.gemini.auto_refresh, |
| 46 | verbose=g_config.gemini.verbose, |
| 47 | refresh_interval=g_config.gemini.refresh_interval, |
| 48 | ) |
| 49 | except Exception: |
| 50 | logger.exception(f"Failed to initialize client {client.id}") |
| 51 | |
| 52 | if client.running(): |
| 53 | success_count += 1 |
| 54 | |
| 55 | if success_count == 0: |
| 56 | raise RuntimeError("Failed to initialize any Gemini clients") |
| 57 | |
| 58 | async def acquire(self, client_id: str | None = None) -> GeminiClientWrapper: |
| 59 | """Return a healthy client by id or using round-robin.""" |
no test coverage detected