Skip to content

Commit

Permalink
Merge branch 'fix-mp-win-3.0' into 'master'
Browse files Browse the repository at this point in the history
Fix multiprocessing on Windows

*Related to:*  #184 

I'm still running into #179 with this fix but all processes start now at least.

BTW the current design is pretty bad regarding memory footprint and bootstrap time as you have to pickle the manager object for *every* subprocess. So this does not only fix multiprocessing on Windows. It improves the multiprocessing design on other platforms, too.

See merge request !97
  • Loading branch information
sigmavirus24 committed Jul 27, 2016
2 parents beee924 + 1f10ed6 commit 846bfaf
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/flake8/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
])


def _run_checks_from_queue(process_queue, results_queue, statistics_queue):
LOG.info('Running checks in parallel')
for checker in iter(process_queue.get, 'DONE'):
LOG.info('Checking "%s"', checker.filename)
checker.run_checks(results_queue, statistics_queue)
results_queue.put('DONE')


class Manager(object):
"""Manage the parallelism and checker instances for each plugin and file.
Expand Down Expand Up @@ -215,13 +223,6 @@ def _handle_results(self, filename, results):
)
return reported_results_count

def _run_checks_from_queue(self):
LOG.info('Running checks in parallel')
for checker in iter(self.process_queue.get, 'DONE'):
LOG.info('Checking "%s"', checker.filename)
checker.run_checks(self.results_queue, self.statistics_queue)
self.results_queue.put('DONE')

def is_path_excluded(self, path):
# type: (str) -> bool
"""Check if a path is excluded.
Expand Down Expand Up @@ -309,7 +310,9 @@ def run_parallel(self):
LOG.info('Starting %d process workers', self.jobs)
for i in range(self.jobs):
proc = multiprocessing.Process(
target=self._run_checks_from_queue
target=_run_checks_from_queue,
args=(self.process_queue, self.results_queue,
self.statistics_queue)
)
proc.daemon = True
proc.start()
Expand Down

0 comments on commit 846bfaf

Please sign in to comment.