From e4cc9fcba73b1614781d398e30ef1aa098fa6841 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Mon, 23 Mar 2020 01:06:55 -0700 Subject: [PATCH] Wrong number of threads to use shown when OMP_THREAD_LIMIT is defined --- src/ocrmypdf/_sync.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ocrmypdf/_sync.py b/src/ocrmypdf/_sync.py index a4c18b21..c397b3f4 100644 --- a/src/ocrmypdf/_sync.py +++ b/src/ocrmypdf/_sync.py @@ -245,6 +245,10 @@ def exec_concurrent(context): if context.options.tesseract_env is None: context.options.tesseract_env = os.environ.copy() context.options.tesseract_env.setdefault('OMP_THREAD_LIMIT', str(tess_threads)) + try: + tess_threads = int(context.options.tesseract_env['OMP_THREAD_LIMIT']) + except ValueError: # OMP_THREAD_LIMIT initialized to non-numeric + context.log.error("Environment variable OMP_THREAD_LIMIT is not numeric") if tess_threads > 1: context.log.info("Using Tesseract OpenMP thread limit %d", tess_threads)