mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-16 09:09:52 +00:00
Tidy up last few bits for performance improvement
This commit is contained in:
parent
109f5f8888
commit
9b8f038a97
3 changed files with 15 additions and 10 deletions
|
|
@ -25,3 +25,4 @@ Contributors (by order of appearance) :
|
||||||
- Tyrel Souza
|
- Tyrel Souza
|
||||||
- Corey Farwell
|
- Corey Farwell
|
||||||
- Michael Penkov
|
- Michael Penkov
|
||||||
|
- Anthony Sottile
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
You can view the `3.3.0 milestone`_ on GitLab for more details.
|
You can view the `3.3.0 milestone`_ on GitLab for more details.
|
||||||
|
|
||||||
|
- Dramatically improve the performance of Flake8 (`GitLab!156`_)
|
||||||
|
|
||||||
- Fix problem where hooks should only check \*.py files. (See also
|
- Fix problem where hooks should only check \*.py files. (See also
|
||||||
`GitLab#268`_)
|
`GitLab#268`_)
|
||||||
|
|
||||||
|
|
@ -14,3 +16,5 @@ You can view the `3.3.0 milestone`_ on GitLab for more details.
|
||||||
https://gitlab.com/pycqa/flake8/milestones/16
|
https://gitlab.com/pycqa/flake8/milestones/16
|
||||||
.. _GitLab#268:
|
.. _GitLab#268:
|
||||||
https://gitlab.com/pycqa/flake8/issues/268
|
https://gitlab.com/pycqa/flake8/issues/268
|
||||||
|
.. _GitLab!156:
|
||||||
|
https://gitlab.com/pycqa/flake8/merge_requests/156
|
||||||
|
|
|
||||||
|
|
@ -92,11 +92,6 @@ class Manager(object):
|
||||||
raise
|
raise
|
||||||
self.using_multiprocessing = False
|
self.using_multiprocessing = False
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _cleanup_queue(q):
|
|
||||||
while not q.empty():
|
|
||||||
q.get_nowait()
|
|
||||||
|
|
||||||
def _process_statistics(self):
|
def _process_statistics(self):
|
||||||
for checker in self.checkers:
|
for checker in self.checkers:
|
||||||
for statistic in defaults.STATISTIC_NAMES:
|
for statistic in defaults.STATISTIC_NAMES:
|
||||||
|
|
@ -279,10 +274,15 @@ class Manager(object):
|
||||||
"""Run the checkers in parallel."""
|
"""Run the checkers in parallel."""
|
||||||
final_results = collections.defaultdict(list)
|
final_results = collections.defaultdict(list)
|
||||||
final_statistics = collections.defaultdict(dict)
|
final_statistics = collections.defaultdict(dict)
|
||||||
for ret in self.pool.imap_unordered(
|
pool_map = self.pool.imap_unordered(
|
||||||
_run_checks, self.checkers,
|
_run_checks,
|
||||||
chunksize=_pool_chunksize(len(self.checkers), self.jobs),
|
self.checkers,
|
||||||
):
|
chunksize=calculate_pool_chunksize(
|
||||||
|
len(self.checkers),
|
||||||
|
self.jobs,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
for ret in pool_map:
|
||||||
filename, results, statistics = ret
|
filename, results, statistics = ret
|
||||||
final_results[filename] = results
|
final_results[filename] = results
|
||||||
final_statistics[filename] = statistics
|
final_statistics[filename] = statistics
|
||||||
|
|
@ -620,7 +620,7 @@ def _pool_init():
|
||||||
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
||||||
|
|
||||||
|
|
||||||
def _pool_chunksize(num_checkers, num_jobs):
|
def calculate_pool_chunksize(num_checkers, num_jobs):
|
||||||
"""Determine the chunksize for the multiprocessing Pool.
|
"""Determine the chunksize for the multiprocessing Pool.
|
||||||
|
|
||||||
- For chunksize, see: https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.Pool.imap # noqa
|
- For chunksize, see: https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.Pool.imap # noqa
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue