From e9029a6b3a7e8ac47368b8ddf4055e9259c0361f Mon Sep 17 00:00:00 2001 From: Andrew Halberstadt Date: Thu, 23 Jan 2020 13:31:44 +0000 Subject: [PATCH] Bug 1608535 - [mozlint] Add an option to specify the number of processes to spawn, r=Standard8 This is a ride-along commit that would have made debugging the problem solved by this bug easier. Depends on D60688 Differential Revision: https://phabricator.services.mozilla.com/D60689 --HG-- extra : moz-landing-system : lando --- python/mozlint/mozlint/cli.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/python/mozlint/mozlint/cli.py b/python/mozlint/mozlint/cli.py index a61a0f7f6e04..2c8acce33d25 100644 --- a/python/mozlint/mozlint/cli.py +++ b/python/mozlint/mozlint/cli.py @@ -96,6 +96,13 @@ class MozlintParser(ArgumentParser): 'default': False, 'help': "Bootstrap linter dependencies without running any of the linters." }], + [['-j', '--jobs'], + {'default': None, + 'dest': 'num_procs', + 'type': int, + 'help': "Number of worker processes to spawn when running linters. " + "Defaults to the number of cores in your CPU.", + }], [['extra_args'], {'nargs': REMAINDER, 'help': "Extra arguments that will be forwarded to the underlying linter.", @@ -181,7 +188,7 @@ def find_linters(linters=None): def run(paths, linters, formats, outgoing, workdir, edit, - setup=False, list_linters=False, **lintargs): + setup=False, list_linters=False, num_procs=None, **lintargs): from mozlint import LintRoller, formatters from mozlint.editor import edit_issues @@ -201,11 +208,11 @@ def run(paths, linters, formats, outgoing, workdir, edit, return ret # run all linters - result = lint.roll(paths, outgoing=outgoing, workdir=workdir) + result = lint.roll(paths, outgoing=outgoing, workdir=workdir, num_procs=num_procs) if edit and result.issues: edit_issues(result) - result = lint.roll(result.issues.keys()) + result = lint.roll(result.issues.keys(), num_procs=num_procs) for formatter_name, path in formats: formatter = formatters.get(formatter_name)