From 82285a8e6cf1adef0f624eeb854612aced562bb4 Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Thu, 2 Jul 2020 11:49:35 +0200 Subject: [PATCH] better multithreading --- ocr | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocr b/ocr index 26fc532..a857931 100755 --- a/ocr +++ b/ocr @@ -226,6 +226,7 @@ class OCRPipeline(WorkflowRunner): ' ################################################## ''' combined_pdf_creation_jobs = [] + n_cores = min(self.n_cores, max(1, int(self.n_cores / len(self.jobs)))) for i, job in enumerate(self.jobs): input_dir = os.path.join(job.output_dir, 'tmp') output_dir = job.output_dir @@ -237,6 +238,7 @@ class OCRPipeline(WorkflowRunner): cmd = 'gs' cmd += ' -dBATCH' cmd += ' -dNOPAUSE' + cmd += ' -dNumRenderingThreads={}'.format(n_cores) cmd += ' -dPDFSETTINGS=/ebook' cmd += ' -dQUIET' cmd += ' -sDEVICE=pdfwrite' @@ -247,7 +249,8 @@ class OCRPipeline(WorkflowRunner): lbl = 'combined_pdf_creation_-_{}'.format(i) combined_pdf_creation_jobs.append(self.addTask(command=cmd, dependencies=deps, - label=lbl)) + label=lbl, + nCores=n_cores)) ''' ' ##################################################