[diffoscope] 03/06: difference: adds condition for parallel execution
Juliana Oliveira
jwnx-guest at moszumanska.debian.org
Tue Jan 23 22:03:35 CET 2018
This is an automated email from the git hooks/post-receive script.
jwnx-guest pushed a commit to branch jwnx_parallel_diffoscope
in repository diffoscope.
commit 44dbf9dab95d68a8732c2478ffb8d6871445342e
Author: Juliana Oliveira <juliana.orod at gmail.com>
Date: Tue Jan 16 11:06:53 2018 -0200
difference: adds condition for parallel execution
If Config().parallel is True, loads ComparisonPool class and
uses .map method. Else, fallsback to serial.
Signed-off-by: Juliana Oliveira <juliana.orod at gmail.com>
---
diffoscope/difference.py | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/diffoscope/difference.py b/diffoscope/difference.py
index 4f7e994..526b81e 100644
--- a/diffoscope/difference.py
+++ b/diffoscope/difference.py
@@ -25,8 +25,8 @@ from . import feeders
from .exc import RequiredToolNotFound
from .diff import diff, reverse_unified_diff, diff_split_lines
from .excludes import command_excluded
-from .parallel.comparison_pool import ComparisonPool, \
- CommandFailedToExecute
+from .config import Config
+
logger = logging.getLogger(__name__)
@@ -251,13 +251,18 @@ class Difference(object):
command.start()
return feeder, command, False
- pool = ComparisonPool()
results = {}
- try:
- pool.map(command_and_feeder, args=[path1, path2], callback=results)
- except CommandFailedToExecute as e:
- logger.debug("Command failed while executing %s", e)
+ if Config.parallel:
+ from .parallel.comparison_pool import ComparisonPool, \
+ CommandFailedToExecute
+ pool = ComparisonPool()
+
+ try:
+ pool.map(command_and_feeder, args=[path1, path2],
+ callback=results)
+ except CommandFailedToExecute as e:
+ logger.debug("Command failed while executing %s", e)
if not results:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list