From 5f685aef6e79a1e477ec39520d79e89010e8e58c Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Mon, 8 Dec 2025 23:20:59 -0800 Subject: [PATCH] fix: handle None jobs in concurrent processing Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) --- src/ocrmypdf/_pipelines/ocr.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ocrmypdf/_pipelines/ocr.py b/src/ocrmypdf/_pipelines/ocr.py index 9a194871..853e3c98 100644 --- a/src/ocrmypdf/_pipelines/ocr.py +++ b/src/ocrmypdf/_pipelines/ocr.py @@ -49,6 +49,7 @@ from ocrmypdf._validation import ( create_input_file, ) from ocrmypdf.exceptions import ExitCode +from ocrmypdf.helpers import available_cpu_count log = logging.getLogger(__name__) @@ -96,7 +97,8 @@ def _exec_page_sync(page_context: PageContext) -> PageResult: def exec_concurrent(context: PdfContext, executor: Executor) -> Sequence[str]: """Execute the OCR pipeline concurrently.""" options = context.options - max_workers = min(len(context.pdfinfo), options.jobs) + jobs = options.jobs or available_cpu_count() + max_workers = min(len(context.pdfinfo), jobs) if max_workers > 1: log.info("Start processing %d pages concurrently", max_workers)