Skip to content

Commit b35575d

Browse files
committed
Add --jobs option
1 parent ef48977 commit b35575d

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎runtests.py‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ def parse_args():
6868
parser.add_argument('-c', '--current', action="store_true",
6969
help="Only test the current Python executable "
7070
"(don't test multiple Python versions)")
71+
parser.add_argument('-j', '--jobs', type=int,
72+
help="Number of jobs run in parallel")
7173
return parser.parse_args()
7274

7375

@@ -95,10 +97,12 @@ def worker(executable):
9597
cmd = get_test_command(executable, args.verbose, build_dir)
9698
return get_output(cmd)
9799

98-
if hasattr(os, 'process_cpu_count'):
99-
max_workers = os.process_cpu_count()
100-
else:
101-
max_workers = os.cpu_count()
100+
max_workers = args.jobs
101+
if not max_workers:
102+
if hasattr(os, 'process_cpu_count'):
103+
max_workers = os.process_cpu_count()
104+
else:
105+
max_workers = os.cpu_count()
102106

103107
print()
104108
print(f"Run {len(jobs)} jobs with {max_workers} workers (threads)")
@@ -107,7 +111,7 @@ def worker(executable):
107111
with ThreadPoolExecutor(max_workers=max_workers) as executor:
108112
exitcode = None
109113
for exitcode, stdout in executor.map(worker, jobs):
110-
print(stdout, end='')
114+
print(stdout, end='', flush=True)
111115
if exitcode:
112116
break
113117

0 commit comments

Comments
 (0)