MCPcopy Create free account
hub / github.com/Nativu5/Gemini-FastAPI / init

Method init

app/services/pool.py:36–56  ·  view source on GitHub ↗

Initialize all clients in the pool.

(self)

Source from the content-addressed store, hash-verified

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."""

Callers 3

lifespanFunction · 0.95
health_checkFunction · 0.95
_ensure_client_readyMethod · 0.45

Calls 1

runningMethod · 0.80

Tested by

no test coverage detected