From bfeed0e590060538b191d11e3f952f19d22487bd Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Fri, 20 Feb 2026 17:36:28 -0800 Subject: [PATCH] fix: also close sync clients on eviction from LLMClientCache --- litellm/caching/llm_caching_handler.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/litellm/caching/llm_caching_handler.py b/litellm/caching/llm_caching_handler.py index 5df9a8e4cdd..5dc16a224c7 100644 --- a/litellm/caching/llm_caching_handler.py +++ b/litellm/caching/llm_caching_handler.py @@ -21,6 +21,11 @@ class LLMClientCache(InMemoryCache): asyncio.get_running_loop().create_task(close_fn()) except RuntimeError: pass + elif close_fn and callable(close_fn): + try: + close_fn() + except Exception: + pass def update_cache_key_with_event_loop(self, key): """