The problem: a PDF ingest that blocks for minutes

My ingest endpoint was synchronous. Upload a file, wait for OCR, wait for the LLM extraction pipeline, get a response. On a small note it took 3–5 seconds. On a dense PDF it could run for minutes. The original code even had a comment explaining the awkwardness:

@router.post("/ingest", response_model=list[IngestResult])

def ingest(file: UploadFile) -> list[IngestResult]:

# Sync endpoint on purpose: the ingestion pipeline calls anyio.run()