summaryrefslogtreecommitdiff
path: root/src/flake8
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2019-02-16 17:28:31 -0800
committerAnthony Sottile <asottile@umich.edu>2019-02-17 00:15:00 -0800
commite8f43e12431b15e31a265408b6f79955c6da1690 (patch)
treeddd3b142a94664169e97f564c24f4e02ca06ab82 /src/flake8
parent684ffb3306af89e4092c4598aa9ae4294eb52eb8 (diff)
downloadflake8-e8f43e12431b15e31a265408b6f79955c6da1690.tar.gz
Speed up flake8 when only 1 filename is passed
~40% improvement over status quo (perf measurements are best-of-5) ### before ```console $ time flake8 /dev/null real 0m0.337s user 0m0.212s sys 0m0.028s ``` ### after ```console $ time flake8 /dev/null real 0m0.197s user 0m0.182s sys 0m0.012s ```
Diffstat (limited to 'src/flake8')
-rw-r--r--src/flake8/checker.py10
1 files changed, 1 insertions, 9 deletions
diff --git a/src/flake8/checker.py b/src/flake8/checker.py
index 138bb4f..34db7db 100644
--- a/src/flake8/checker.py
+++ b/src/flake8/checker.py
@@ -73,7 +73,6 @@ class Manager(object):
self.options = style_guide.options
self.checks = checker_plugins
self.jobs = self._job_count()
- self.using_multiprocessing = self.jobs > 1
self.processes = []
self.checkers = []
self.statistics = {
@@ -279,7 +278,6 @@ class Manager(object):
except OSError as oserr:
if oserr.errno not in SERIAL_RETRY_ERRNOS:
raise
- self.using_multiprocessing = False
self.run_serial()
return
@@ -326,16 +324,10 @@ class Manager(object):
fallback to serial processing.
"""
try:
- if self.using_multiprocessing:
+ if self.jobs > 1 and len(self.checkers) > 1:
self.run_parallel()
else:
self.run_serial()
- except OSError as oserr:
- if oserr.errno not in SERIAL_RETRY_ERRNOS:
- LOG.exception(oserr)
- raise
- LOG.warning("Running in serial after OS exception, %r", oserr)
- self.run_serial()
except KeyboardInterrupt:
LOG.warning("Flake8 was interrupted by the user")
raise exceptions.EarlyQuit("Early quit while running checks")