diff --git a/litellm/caching.py b/litellm/caching.py index 64488289a8..0812d8c6bb 100644 --- a/litellm/caching.py +++ b/litellm/caching.py @@ -248,9 +248,15 @@ class RedisCache(BaseCache): # asyncio.get_running_loop().create_task(self.ping()) result = asyncio.get_running_loop().create_task(self.ping()) except Exception as e: - verbose_logger.error( - "Error connecting to Async Redis client", extra={"error": str(e)} - ) + if "no running event loop" in str(e): + verbose_logger.debug( + "Ignoring async redis ping. No running event loop." + ) + else: + verbose_logger.error( + "Error connecting to Async Redis client - {}".format(str(e)), + extra={"error": str(e)}, + ) ### SYNC HEALTH PING ### try: diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index 2c19d3925f..381bcc1ac9 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -600,8 +600,7 @@ class Logging: verbose_logger.error( "LiteLLM.LoggingError: [Non-Blocking] Exception occurred while building complete streaming response in success logging {}\n{}".format( str(e), traceback.format_exc() - ), - log_level="ERROR", + ) ) complete_streaming_response = None else: diff --git a/litellm/tests/test_caching.py b/litellm/tests/test_caching.py index c5e9c7f1fc..fa35f75de2 100644 --- a/litellm/tests/test_caching.py +++ b/litellm/tests/test_caching.py @@ -1607,7 +1607,17 @@ def test_caching_redis_simple(caplog): print(m) print(time.time() - s2) + redis_async_caching_error = False + redis_service_logging_error = False captured_logs = [rec.message for rec in caplog.records] - assert "LiteLLM Redis Caching: async set" not in captured_logs - assert "ServiceLogging.async_service_success_hook" not in captured_logs + print(f"captured_logs: {captured_logs}") + for item in captured_logs: + if "Error connecting to Async Redis client" in item: + redis_async_caching_error = True + + if "ServiceLogging.async_service_success_hook" in item: + redis_service_logging_error = True + + assert redis_async_caching_error is False + assert redis_service_logging_error is False