From 8914d2686718ef3e2ad55ca0f96fc28082aa8f38 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Thu, 24 Aug 2023 08:26:56 +0200 Subject: rebuild-index: fix race condition by avoiding parallelism (#39594) --- lib/spack/spack/binary_distribution.py | 35 ++++++++++------------------------ 1 file changed, 10 insertions(+), 25 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/binary_distribution.py b/lib/spack/spack/binary_distribution.py index 7ba8b5ff07..abca0531df 100644 --- a/lib/spack/spack/binary_distribution.py +++ b/lib/spack/spack/binary_distribution.py @@ -9,7 +9,6 @@ import hashlib import io import itertools import json -import multiprocessing.pool import os import re import shutil @@ -876,32 +875,18 @@ def _read_specs_and_push_index(file_list, read_method, cache_prefix, db, temp_di db: A spack database used for adding specs and then writing the index. temp_dir (str): Location to write index.json and hash for pushing concurrency (int): Number of parallel processes to use when fetching - - Return: - None """ + for file in file_list: + contents = read_method(file) + # Need full spec.json name or this gets confused with index.json. + if file.endswith(".json.sig"): + specfile_json = Spec.extract_json_from_clearsig(contents) + fetched_spec = Spec.from_dict(specfile_json) + elif file.endswith(".json"): + fetched_spec = Spec.from_json(contents) + else: + continue - def _fetch_spec_from_mirror(spec_url): - spec_file_contents = read_method(spec_url) - - if spec_file_contents: - # Need full spec.json name or this gets confused with index.json. - if spec_url.endswith(".json.sig"): - specfile_json = Spec.extract_json_from_clearsig(spec_file_contents) - return Spec.from_dict(specfile_json) - if spec_url.endswith(".json"): - return Spec.from_json(spec_file_contents) - - tp = multiprocessing.pool.ThreadPool(processes=concurrency) - try: - fetched_specs = tp.map( - llnl.util.lang.star(_fetch_spec_from_mirror), [(f,) for f in file_list] - ) - finally: - tp.terminate() - tp.join() - - for fetched_spec in fetched_specs: db.add(fetched_spec, None) db.mark(fetched_spec, "in_buildcache", True) -- cgit v1.2.3-70-g09d2