From 3cbbf4fef6f5f27c112d165297864007ea371838 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 5 Aug 2026 17:47:19 +0000 Subject: [PATCH] refactor(proxy): expose engine_generation/recreate_in_flight on PrismaWrapper Reads the planned-recreate coordination through public PrismaWrapper accessors instead of touching private fields from PrismaClient, keeping reportPrivateUsage within the basedpyright budget. --- litellm/proxy/db/prisma_client.py | 8 ++++++++ litellm/proxy/utils.py | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/db/prisma_client.py b/litellm/proxy/db/prisma_client.py index 6863687081c..def3fb72bcb 100644 --- a/litellm/proxy/db/prisma_client.py +++ b/litellm/proxy/db/prisma_client.py @@ -241,6 +241,14 @@ class PrismaWrapper: self._engine_generation: int = 0 self.on_engine_replaced: Callable[[], None] | None = None + @property + def engine_generation(self) -> int: + return self._engine_generation + + @property + def recreate_in_flight(self) -> bool: + return self._reconnection_lock.locked() + @staticmethod def _read_engine(prisma_client: _PrismaClient) -> _PrismaEngine: return prisma_client._engine diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 2eafa6fbc38..5dc2da84de7 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -4971,12 +4971,12 @@ class PrismaClient: return (self.db,) def _engine_generations(self) -> tuple[int, ...]: - return tuple(w._engine_generation for w in self._prisma_wrappers()) + return tuple(w.engine_generation for w in self._prisma_wrappers()) def _is_planned_engine_recreate_error(self, e: Exception, generations_before: tuple[int, ...]) -> bool: if not PrismaDBExceptionHandler.is_database_transport_error(e): return False - if any(w._reconnection_lock.locked() for w in self._prisma_wrappers()): + if any(w.recreate_in_flight for w in self._prisma_wrappers()): return True return self._engine_generations() != generations_before