From 5b268e59ad23552345aea6b7202544963e9fe86a Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 7 Mar 2026 03:24:16 +0000 Subject: [PATCH] fix: make test_redaction_responses_api_stream resilient to async callback timing Replace fixed 1s sleep with polling wait for async_log_success_event. Streaming success handler runs via asyncio.create_task; 1s was insufficient in CI. Add 0.5s initial sleep for event loop to schedule the task, then poll up to 10s for the callback to fire. Co-authored-by: Ishaan Jaff --- .../test_logging_redaction_e2e_test.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/logging_callback_tests/test_logging_redaction_e2e_test.py b/tests/logging_callback_tests/test_logging_redaction_e2e_test.py index e70d08b9008..0536ec72057 100644 --- a/tests/logging_callback_tests/test_logging_redaction_e2e_test.py +++ b/tests/logging_callback_tests/test_logging_redaction_e2e_test.py @@ -203,8 +203,13 @@ async def test_redaction_responses_api_stream(): chunks = [] async for chunk in response: chunks.append(chunk) - - await asyncio.sleep(1) + + # Wait for async success callback to fire (streaming logs run via asyncio.create_task) + await asyncio.sleep(0.5) # Let event loop schedule the create_task'd success handler + for _ in range(100): # Up to 10 seconds total + if test_custom_logger.logged_standard_logging_payload is not None: + break + await asyncio.sleep(0.1) standard_logging_payload = test_custom_logger.logged_standard_logging_payload assert standard_logging_payload is not None