The reconnect() function creates a new connection but does not close the old HTTP client.
File: src/opengradient/client/tee_connection.py (lines 153–160)
In RegistryTEEConnection.reconnect(), a new connection is created, but the old HTTP client is not closed.
In another class (StaticTEEConnection.reconnect()), the old client is properly closed before replacing it. But here, that step is missing.
If the app runs for a long time and reconnects often (like every 5 minutes), many unused HTTP connections stay open.
This can slowly use up system resources (file descriptors) and may cause problems later.
async def reconnect(self) -> None:
async with self._refresh_lock:
try:
self._active = self._connect() # old client is never closed
except Exception:
logger.debug("Failed to close previous HTTP client during TEE refresh.", exc_info=True)
Before creating a new connection, the old HTTP client should be properly closed
Hope this could fix out:
async def reconnect(self) -> None:
async with self._refresh_lock:
old_client = self._active.http_client
try:
self._active = self._connect()
except Exception:
logger.debug("Failed to reconnect TEE.", exc_info=True)
return
try:
await old_client.aclose()
except Exception:
logger.debug("Failed to close previous HTTP client during TEE refresh.", exc_info=True)
The reconnect() function creates a new connection but does not close the old HTTP client.
File: src/opengradient/client/tee_connection.py (lines 153–160)
In RegistryTEEConnection.reconnect(), a new connection is created, but the old HTTP client is not closed.
In another class (StaticTEEConnection.reconnect()), the old client is properly closed before replacing it. But here, that step is missing.
If the app runs for a long time and reconnects often (like every 5 minutes), many unused HTTP connections stay open.
This can slowly use up system resources (file descriptors) and may cause problems later.
async def reconnect(self) -> None:
async with self._refresh_lock:
try:
self._active = self._connect() # old client is never closed
except Exception:
logger.debug("Failed to close previous HTTP client during TEE refresh.", exc_info=True)
Before creating a new connection, the old HTTP client should be properly closed
Hope this could fix out:
async def reconnect(self) -> None:
async with self._refresh_lock:
old_client = self._active.http_client
try:
self._active = self._connect()
except Exception:
logger.debug("Failed to reconnect TEE.", exc_info=True)
return
try:
await old_client.aclose()
except Exception:
logger.debug("Failed to close previous HTTP client during TEE refresh.", exc_info=True)