mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-13 08:04:18 +00:00
Accept 'auto' for --jobs, and default to cpu_count(); issue #151
This commit is contained in:
parent
ed6d0398bc
commit
f40cf8e030
1 changed files with 17 additions and 7 deletions
|
|
@ -51,8 +51,9 @@ def get_parser():
|
||||||
|
|
||||||
if multiprocessing:
|
if multiprocessing:
|
||||||
parser.config_options.append('jobs')
|
parser.config_options.append('jobs')
|
||||||
parser.add_option('-j', '--jobs', type='int', default=1,
|
parser.add_option('-j', '--jobs', type='string', default='',
|
||||||
help="number of jobs to run simultaneously")
|
help="number of jobs to run simultaneously, "
|
||||||
|
"or 'auto'")
|
||||||
|
|
||||||
parser.add_option('--exit-zero', action='store_true',
|
parser.add_option('--exit-zero', action='store_true',
|
||||||
help="exit with code 0 even if there are errors")
|
help="exit with code 0 even if there are errors")
|
||||||
|
|
@ -87,11 +88,20 @@ def get_style_guide(**kwargs):
|
||||||
for options_hook in options_hooks:
|
for options_hook in options_hooks:
|
||||||
options_hook(options)
|
options_hook(options)
|
||||||
|
|
||||||
if multiprocessing and options.jobs > 1:
|
if multiprocessing and options.jobs:
|
||||||
reporter = BaseQReport if options.quiet else QueueReport
|
if options.jobs.isdigit():
|
||||||
report = styleguide.init_report(reporter)
|
n_jobs = int(options.jobs)
|
||||||
report.input_file = styleguide.input_file
|
else:
|
||||||
styleguide.runner = report.task_queue.put
|
try:
|
||||||
|
n_jobs = multiprocessing.cpu_count()
|
||||||
|
except NotImplementedError:
|
||||||
|
n_jobs = 1
|
||||||
|
if n_jobs > 1:
|
||||||
|
options.jobs = n_jobs
|
||||||
|
reporter = BaseQReport if options.quiet else QueueReport
|
||||||
|
report = styleguide.init_report(reporter)
|
||||||
|
report.input_file = styleguide.input_file
|
||||||
|
styleguide.runner = report.task_queue.put
|
||||||
|
|
||||||
return styleguide
|
return styleguide
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue