Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(logging_worker): clear flushed task refs in the shape memory_test expects

mateo-berric769562b5f1c
diff --git a/litellm/litellm_core_utils/logging_worker.py b/litellm/litellm_core_utils/logging_worker.py
index b5aca3bcdb9..c5da732f63c 100644
--- a/litellm/litellm_core_utils/logging_worker.py
+++ b/litellm/litellm_core_utils/logging_worker.py
@@ -564,10 +564,12 @@ class LoggingWorker:
# Run the coroutine synchronously in new loop
# Note: We run the coroutine directly, not via create_task,
# since we're in a new event loop context
- if self._run_coroutine_silently(loop, task["coroutine"]):
- processed += 1
- # Clear reference to prevent memory leaks
- task = None
+ try:
+ if self._run_coroutine_silently(loop, task["coroutine"]):
+ processed += 1
+ finally:
+ # Clear reference to prevent memory leaks
+ task = None
finally:
logging.raiseExceptions = previous_raise_exceptions