Skip to content

Conversation

@GulSauce
Copy link
Member

@GulSauce GulSauce commented Jan 5, 2026

📢 설명

해당 Pull Request에 대해 간략하게 설명해주세요!

✅ 체크 리스트

  • 리뷰어가 체크할 내용을 작성해주세요!

Summary by CodeRabbit

Release Notes

  • New Features

    • Batch request processing now supports explicit timeout parameters with partial result completion capabilities.
    • Added asynchronous request handling with configurable timeout support for improved control.
  • Improvements

    • Enhanced error handling with comprehensive logging for timeout events and exceptions.
    • Transitioned from environment-based timeout configuration to explicit parameters for greater flexibility.

✏️ Tip: You can customize this high-level summary in your review settings.

@GulSauce GulSauce merged commit 9bbc413 into develop Jan 5, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 5, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR refactors request handling to introduce explicit timeout parameters across batch and single request processing. Batch requests now support partial completion via asyncio.wait instead of asyncio.gather, while a new async wrapper enables controlled timeout behavior in single requests. Services are updated to propagate timeout values through the call stack.

Changes

Cohort / File(s) Summary
Request adapter layer
app/adapter/request_batch.py, app/adapter/request_single.py
Batch processing refactored from asyncio.gather to asyncio.wait with timeout support and task cancellation on timeout. Single requests gain async wrapper request_responses_output_text_async with explicit timeout parameter and thread-based execution. Both add enhanced error logging for APITimeoutError and general exceptions.
Service layer
app/service/explanation_service.py, app/service/generate_service.py
Explanation service replaces asyncio.to_thread wrapper with direct async call to new request_responses_output_text_async (timeout=60s). Generate service adds timeout=30s to two request_text_batch invocations.

Sequence Diagram

sequenceDiagram
    actor Client
    participant BatchProc as Batch Processor
    participant TaskMgr as asyncio.wait
    participant Tasks as Concurrent Tasks
    participant OpenAI as OpenAI API
    
    Client->>BatchProc: request_text_batch(..., timeout=30s)
    
    BatchProc->>Tasks: create_task() for each request
    
    rect rgb(240, 248, 255)
        note over TaskMgr,Tasks: New: asyncio.wait with timeout
        TaskProc->>TaskMgr: wait(tasks, timeout=30s)
        par Parallel execution
            Tasks->>OpenAI: API call 1
            Tasks->>OpenAI: API call 2
            Tasks->>OpenAI: API call N
        and Timeout monitoring
            TaskMgr->>TaskMgr: Check elapsed time
        end
    end
    
    alt Timeout occurs
        TaskMgr->>Tasks: Cancel unfinished tasks
        Tasks-->>TaskMgr: Cancelled
        note over BatchProc: Return None for incomplete tasks
    else All complete within timeout
        OpenAI-->>Tasks: Results
        Tasks-->>TaskMgr: Done
    end
    
    TaskMgr-->>BatchProc: (done, pending)
    BatchProc-->>Client: [result1, None, result3, ...]
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Hops through timeouts with grace so grand,
Tasks now wait, not gather as they stand,
Async wrappers catch the fleeting calls,
Thirty seconds—before the timeout falls,
Partial wins when races can't be won!

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1427a9 and dc3b943.

📒 Files selected for processing (4)
  • app/adapter/request_batch.py
  • app/adapter/request_single.py
  • app/service/explanation_service.py
  • app/service/generate_service.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants