Skip to content

Commit

Permalink
cross-platform worker estimation (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
Teque5 authored Jan 15, 2025
1 parent 2fefb43 commit a7d9ae0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sigmf/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a7d9ae0

Please sign in to comment.