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 flaky test_langsmith_queue_logging: poll instead of fixed sleep

yuneng-jiangcc027a2b904c
diff --git a/tests/logging_callback_tests/test_langsmith_unit_test.py b/tests/logging_callback_tests/test_langsmith_unit_test.py
index 17b854b52f2..c7b77f28261 100644
--- a/tests/logging_callback_tests/test_langsmith_unit_test.py
+++ b/tests/logging_callback_tests/test_langsmith_unit_test.py
@@ -475,7 +475,11 @@ async def test_langsmith_queue_logging():
mock_response="This is a mock response",
)
- await asyncio.sleep(3)
+ # Poll for async callbacks to complete (up to 10s)
+ for _ in range(20):
+ if len(test_langsmith_logger.log_queue) >= 5:
+ break
+ await asyncio.sleep(0.5)
# Check that logs are in the queue
assert len(test_langsmith_logger.log_queue) == 5
@@ -490,8 +494,11 @@ async def test_langsmith_queue_logging():
mock_response="This is a mock response",
)
- # Wait a short time for any asynchronous operations to complete
- await asyncio.sleep(1)
+ # Poll for flush to complete (up to 10s)
+ for _ in range(20):
+ if len(test_langsmith_logger.log_queue) < 5:
+ break
+ await asyncio.sleep(0.5)
print(
"Length of langsmith log queue: {}".format(