diff --git a/ypkg2/main.py b/ypkg2/main.py index 0d31606..78d9fc2 100644 --- a/ypkg2/main.py +++ b/ypkg2/main.py @@ -38,6 +38,7 @@ from timeit import default_timer as timer from datetime import timedelta +from concurrent.futures import ThreadPoolExecutor def show_version(): @@ -496,6 +497,7 @@ def build_package(filename, outputDir, buildDir=None): gene.emit_packages() # TODO: Ensure main is always first + package_tasks = [] for package in sorted(gene.packages): pkg = gene.packages[package] files = sorted(pkg.emit_files()) @@ -503,8 +505,14 @@ def build_package(filename, outputDir, buildDir=None): console_ui.emit_info("Package", "Skipping empty package: {}". format(package)) continue + package_tasks.append(pkg) + + def executor_create_eopkg(pkg): metadata.create_eopkg(ctx, gene, pkg, outputDir) + with ThreadPoolExecutor() as executor: + executor.map(executor_create_eopkg, package_tasks) + # Write out the final pspec metadata.write_spec(ctx, gene, outputDir) diff --git a/ypkg2/metadata.py b/ypkg2/metadata.py index dac02e2..41d3ca4 100644 --- a/ypkg2/metadata.py +++ b/ypkg2/metadata.py @@ -398,8 +398,6 @@ def create_eopkg(context, gene, package, outputDir): """ Do the hard work and write the package out """ global history_timestamp - start_time = timer() - name = construct_package_name(context, package) fpath = os.path.join(outputDir, name) @@ -463,9 +461,6 @@ def create_eopkg(context, gene, package, outputDir): format(e)) sys.exit(1) - end_time = timer() - console_ui.emit_info("Package", "{} took {} to emit".format(name, timedelta(seconds=end_time-start_time))) - def write_spec(context, gene, outputDir): """ Write out a compatibility pspec_$ARCH.xml """