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 <ishaan-jaff@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-03-07 03:24:16 +00:00
parent 660f760f93
commit 5b268e59ad

View file

@ -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