Skip to content

Commit 8ee01af

Browse files
committed
cross-platform worker estimation
1 parent c497d9e commit 8ee01af

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sigmf/validate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ def main(arg_tuple: Optional[Tuple[str, ...]] = None) -> None:
121121
n_total = len(paths)
122122
# estimate number of CPU cores
123123
# https://stackoverflow.com/questions/1006289/how-to-find-out-the-number-of-cpus-using-python
124-
est_cpu_cores = len(os.sched_getaffinity(0))
124+
est_num_workers = len(os.sched_getaffinity(0)) if os.name == 'posix' else os.cpu_count()
125125
# create a thread pool
126126
# https://docs.python.org/3.7/library/concurrent.futures.html#threadpoolexecutor
127-
with ThreadPoolExecutor(max_workers=est_cpu_cores - 1) as executor:
127+
with ThreadPoolExecutor(max_workers=est_num_workers) as executor:
128128
# submit jobs
129129
future_validations = {executor.submit(_validate_single_file, path, args.skip_checksum, log) for path in paths}
130130
# load and await jobs to complete... no return

0 commit comments

Comments
 (0)