From b485a1ef78c86baf9f3f10722ea9e60ecc5c94bf Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Sat, 9 Jan 2016 19:07:48 -0800 Subject: [PATCH] Override ruffus' handling of --jobs Ruffus treats omitted parameter as -j1. For our purposes it makes more sense for omitting the parameter to mean "use all CPUs". As such we must be able to distinguish -j1 from the parameter -j being omitted. Telling ruffus to ignore the argument actually just makes it not auto generate the argument. We can add an argument back with the same name. --- ocrmypdf/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ocrmypdf/main.py b/ocrmypdf/main.py index bc80677f..f7f4dcab 100755 --- a/ocrmypdf/main.py +++ b/ocrmypdf/main.py @@ -102,7 +102,7 @@ parser = cmdline.get_argparse( ignored_args=[ 'touch_files_only', 'recreate_database', 'checksum_file_name', 'key_legend_in_graph', 'draw_graph_horizontally', 'flowchart_format', - 'forced_tasks', 'target_tasks', 'use_threads']) + 'forced_tasks', 'target_tasks', 'use_threads', 'jobs']) parser.add_argument( 'input_file', @@ -113,6 +113,9 @@ parser.add_argument( parser.add_argument( '-l', '--language', action='append', help="languages of the file to be OCRed") +parser.add_argument( + '-j', '--jobs', metavar='N', type=int, + help="Use up to N CPU cores simultaneously (default: use all)") metadata = parser.add_argument_group( "Metadata options", @@ -787,7 +790,7 @@ def cleanup_ruffus_error_message(msg): def run_pipeline(): - if not options.jobs or options.jobs == 1: + if not options.jobs: options.jobs = available_cpu_count() try: options.history_file = os.path.join(work_folder, 'ruffus_history.sqlite')