mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
A cached HTTPHandler hands its raw httpx.Client out to consumers that keep it for the process lifetime. When the shared client cache expires the entry on its TTL or evicts it under the 200-entry cap, nothing references the handler, so it is collected and its finalizer closed the client those consumers still hold. Langfuse ingestion then failed silently on the SDK's background flush thread until the process restarted. A finalizer running proves only that nothing references the handler; it proves nothing about the client. Both handlers now close the client during finalization only when they built it and are still its sole referrer, so an unshared client is still released promptly and a handed-out one is left alone. That keeps the pooled-socket reclamation the finalizer was providing, which measures identical to base over 2000 handler create-and-drop cycles. Explicit close() stays, now gated on _owns_client so the wrapper never closes a caller-injected client, and __aexit__ routes through it. LangFuseLogger also keeps a reference to the handler whose client it hands the SDK. Previously that handler was a local that went out of scope immediately, leaving the client reachable only from the SDK. It still shares the cached client, so no extra clients are created per logger. |
||
|---|---|---|
| .. | ||
| test_aiohttp_cleanup_closed.py | ||
| test_aiohttp_handler.py | ||
| test_aiohttp_so_keepalive.py | ||
| test_aiohttp_transport.py | ||
| test_async_client_cleanup.py | ||
| test_credential_leak_prevention.py | ||
| test_gemini_session_leak.py | ||
| test_http_handler.py | ||
| test_llm_http_handler.py | ||
| test_mock_transport.py | ||