Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cross-platform worker estimation #101

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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