Skip to content

Commit 5cc26fe

Browse files
committed
synctiles: automatically detect number of available CPUs
Mypy doesn't know about os.process_cpu_count() yet. Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
1 parent 88286ac commit 5cc26fe

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

demo/_synctiles.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import json
3131
from multiprocessing import Pool
3232
from multiprocessing.pool import Pool as PoolType
33+
import os
3334
from pathlib import Path, PurePath
3435
import re
3536
import sys
@@ -743,6 +744,8 @@ def finish_retile(ctxfile: TextIO, summarydir: Path) -> None:
743744

744745

745746
if __name__ == '__main__':
747+
cpu_count = os.process_cpu_count() # type: ignore[attr-defined]
748+
746749
parser = ArgumentParser()
747750
subparsers = parser.add_subparsers(metavar='subcommand', required=True)
748751

@@ -779,8 +782,8 @@ def finish_retile(ctxfile: TextIO, summarydir: Path) -> None:
779782
metavar='COUNT',
780783
dest='workers',
781784
type=int,
782-
default=4,
783-
help='number of worker processes to start [4]',
785+
default=cpu_count,
786+
help=f'number of worker processes to start [{cpu_count}]',
784787
)
785788
parser_tile.set_defaults(cmd='tile')
786789

0 commit comments

Comments
 (0)