Increase timeout for source creation API calls (#152)

Changed create_source() timeout from default 30s to 300s (5 minutes) to handle
long-running operations like PDF processing with OCR.

Issue:
- PDF imports were timing out after 30 seconds with "Failed to connect to API: timed out"
- PDF processing (especially with OCR/parsing) takes longer than the default timeout
- Users were unable to import PDF documents

Solution:
- Increased timeout to 300 seconds (5 minutes), matching the timeout used by ask_simple()
- This gives sufficient time for document processing operations to complete
- Prevents premature connection timeout errors

Technical Details:
- Modified api/client.py create_source() method
- Added timeout=300.0 parameter to _make_request() call
- Consistent with existing long-running operations (ask_simple uses same timeout)

Testing:
- Users should now be able to import PDFs without timeout errors
- Smaller PDFs will still complete quickly
- Larger PDFs have sufficient time to process
This commit is contained in:
Troy Kelly 2025-10-19 02:55:17 +11:00 committed by GitHub
parent 34a60e515e
commit 9ade6b4b04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -347,7 +347,8 @@ class APIClient:
if transformations:
data["transformations"] = transformations
return self._make_request("POST", "/api/sources/json", json=data)
# Use 5 minute timeout for source creation (especially PDF processing with OCR)
return self._make_request("POST", "/api/sources/json", json=data, timeout=300.0)
def get_source(self, source_id: str) -> Union[Dict[Any, Any], List[Dict[Any, Any]]]:
"""Get a specific source."""