mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
fix(caching.py): fix async redis health check
This commit is contained in:
parent
0a99aa6434
commit
a79cb33960
3 changed files with 22 additions and 7 deletions
|
@ -248,8 +248,14 @@ class RedisCache(BaseCache):
|
|||
# asyncio.get_running_loop().create_task(self.ping())
|
||||
result = asyncio.get_running_loop().create_task(self.ping())
|
||||
except Exception as 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", extra={"error": str(e)}
|
||||
"Error connecting to Async Redis client - {}".format(str(e)),
|
||||
extra={"error": str(e)},
|
||||
)
|
||||
|
||||
### SYNC HEALTH PING ###
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue