Context
The DoclingExtractionProvider.extract() method calls self.converter.convert() which is a synchronous, CPU-heavy operation (ML-based PDF parsing). This blocks the FastAPI event loop and would degrade performance under concurrent requests.
Flagged by Copilot review on PR #15.
Current state
Not an issue right now — this is a single-user local service. The 5MB file size limit also bounds the processing time.
Proposed fix
Wrap the blocking call with run_in_executor:
import asyncio
loop = asyncio.get_event_loop()
result = await loop.run_in_executor(None, self.converter.convert, stream)
When to address
When the service needs to handle concurrent requests or moves beyond single-user local use.
Location
src/pdf-parse/app/services/docling.py — DoclingExtractionProvider.extract() method
Context
The
DoclingExtractionProvider.extract()method callsself.converter.convert()which is a synchronous, CPU-heavy operation (ML-based PDF parsing). This blocks the FastAPI event loop and would degrade performance under concurrent requests.Flagged by Copilot review on PR #15.
Current state
Not an issue right now — this is a single-user local service. The 5MB file size limit also bounds the processing time.
Proposed fix
Wrap the blocking call with
run_in_executor:When to address
When the service needs to handle concurrent requests or moves beyond single-user local use.
Location
src/pdf-parse/app/services/docling.py—DoclingExtractionProvider.extract()method