From 8ee01af2b4b06d8d8b05910f7305aae6426dd218 Mon Sep 17 00:00:00 2001 From: Teque5 Date: Mon, 13 Jan 2025 13:46:41 -0800 Subject: [PATCH] cross-platform worker estimation --- sigmf/validate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sigmf/validate.py b/sigmf/validate.py index 2e450fb..22755c2 100644 --- a/sigmf/validate.py +++ b/sigmf/validate.py @@ -121,10 +121,10 @@ def main(arg_tuple: Optional[Tuple[str, ...]] = None) -> None: n_total = len(paths) # estimate number of CPU cores # https://stackoverflow.com/questions/1006289/how-to-find-out-the-number-of-cpus-using-python - est_cpu_cores = len(os.sched_getaffinity(0)) + est_num_workers = len(os.sched_getaffinity(0)) if os.name == 'posix' else os.cpu_count() # create a thread pool # https://docs.python.org/3.7/library/concurrent.futures.html#threadpoolexecutor - with ThreadPoolExecutor(max_workers=est_cpu_cores - 1) as executor: + with ThreadPoolExecutor(max_workers=est_num_workers) as executor: # submit jobs future_validations = {executor.submit(_validate_single_file, path, args.skip_checksum, log) for path in paths} # load and await jobs to complete... no return