Skip to content

Commit 1dccff7

Browse files
CopilotMte90
andcommitted
Fix embedding timeout mismatch between future and SDK calls
Co-authored-by: Mte90 <403283+Mte90@users.noreply.github.com>
1 parent 7154e32 commit 1dccff7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

ai/analyzer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@
5252
# Increase batch size for parallel processing
5353
EMBEDDING_BATCH_SIZE = 16 # Process embeddings in batches for better throughput
5454
PROGRESS_LOG_INTERVAL = 10 # Log progress every N completed files
55-
EMBEDDING_TIMEOUT = 30 # Timeout in seconds for each embedding API call
55+
# Timeout for future.result() must account for retries: (max_retries + 1) × SDK_timeout + buffer
56+
# With SDK timeout of 15s and max_retries=2, this allows 3 × 15s = 45s + 15s buffer = 60s
57+
EMBEDDING_TIMEOUT = 60 # Timeout in seconds for each embedding API call (including retries)
5658
FILE_PROCESSING_TIMEOUT = 300 # Timeout in seconds for processing a single file (5 minutes)
5759
_THREADPOOL_WORKERS = max(16, EMBEDDING_CONCURRENCY + 8)
5860
_EXECUTOR = concurrent.futures.ThreadPoolExecutor(max_workers=_THREADPOOL_WORKERS)

ai/openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def __init__(self,
122122
api_url: Optional[str] = None,
123123
api_key: Optional[str] = None,
124124
model: Optional[str] = None,
125-
timeout: float = 30.0,
125+
timeout: float = 15.0,
126126
max_retries: int = 2,
127127
backoff: float = 1.5):
128128
self.api_url = api_url or CFG.get("api_url")

0 commit comments

Comments
 (0)