Skip to content

Commit ab09d7a

Browse files
CopilotMte90
andcommitted
Add detailed diagnostic information for future timeouts
- Show elapsed time, chunk size, and chunk preview when timeout occurs - Display future state to understand if still running or finished - Explain that future.result() timed out and request may still be running - Direct users to check worker thread logs for more details Co-authored-by: Mte90 <403283+Mte90@users.noreply.github.com>
1 parent afacea9 commit ab09d7a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

ai/analyzer.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ def _process_file_sync(
202202
saved_count = 0
203203
failed_count = 0
204204
for idx, chunk_doc, future, embedding_start_time in embedding_futures:
205+
chunk_text = chunk_doc.text
206+
chunk_size = len(chunk_text)
207+
chunk_preview = chunk_text[:200] + "..." if len(chunk_text) > 200 else chunk_text
208+
205209
try:
206210
emb = future.result(timeout=EMBEDDING_TIMEOUT) # Add timeout to prevent hanging indefinitely
207211
embedding_duration = time.time() - embedding_start_time
@@ -210,7 +214,17 @@ def _process_file_sync(
210214
if embedding_duration > 5.0:
211215
logger.warning(f"Slow embedding API response for {rel_path} chunk {idx}: {embedding_duration:.2f}s total")
212216
except concurrent.futures.TimeoutError:
213-
logger.error(f"Embedding API timeout ({EMBEDDING_TIMEOUT}s) for {rel_path} chunk {idx} - The embedding request did not complete within {EMBEDDING_TIMEOUT}s. This may indicate network issues, API overload, or the chunk being too large.")
217+
elapsed = time.time() - embedding_start_time
218+
logger.error(
219+
f"Future timeout ({EMBEDDING_TIMEOUT}s) for {rel_path} chunk {idx}:\n"
220+
f" - Elapsed time: {elapsed:.2f}s\n"
221+
f" - Chunk size: {chunk_size} characters\n"
222+
f" - Chunk preview: {chunk_preview!r}\n"
223+
f" - Future state: {future._state if hasattr(future, '_state') else 'unknown'}\n"
224+
f" - The future.result() call timed out waiting for the embedding API.\n"
225+
f" - The embedding request may still be running in the background thread.\n"
226+
f" - Check logs above for 'Embedding API Timeout' messages from the worker thread."
227+
)
214228
emb = None
215229
failed_count += 1
216230
except Exception as e:

0 commit comments

Comments
 (0)