[diffoscope] 08/10: difference: adds error treatment to ComparisonPool.map(command_and_feeder)

Juliana Oliveira jwnx-guest at moszumanska.debian.org
Sun Jan 14 21:04: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 c9119c0b97bb2fee47b9ac01c1547fd0b4616aef
Author: Juliana Oliveira <juliana.orod at gmail.com>
Date:   Sun Jan 14 17:32:02 2018 -0200

    difference: adds error treatment to ComparisonPool.map(command_and_feeder)
    
    Signed-off-by: Juliana Oliveira <juliana.orod at gmail.com>
---
 diffoscope/difference.py | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/diffoscope/difference.py b/diffoscope/difference.py
index 965e395..4f7e994 100644
--- a/diffoscope/difference.py
+++ b/diffoscope/difference.py
@@ -19,12 +19,14 @@
 
 import heapq
 import logging
+import dill
 
 from . import feeders
 from .exc import RequiredToolNotFound
 from .diff import diff, reverse_unified_diff, diff_split_lines
 from .excludes import command_excluded
-from diffoscope.parallel.comparison_pool import pool
+from .parallel.comparison_pool import ComparisonPool, \
+                                      CommandFailedToExecute
 
 logger = logging.getLogger(__name__)
 
@@ -231,6 +233,7 @@ class Difference(object):
 
     @staticmethod
     def from_command_exc(klass, path1, path2, *args, **kwargs):
+        logger.debug("Starting execution of command %s", klass)
         command_args = []
         if 'command_args' in kwargs:
             command_args = kwargs['command_args']
@@ -248,10 +251,23 @@ class Difference(object):
                 command.start()
             return feeder, command, False
 
+        pool = ComparisonPool()
+        results = {}
 
-        [[feeder1, command1, excluded1],
-         [feeder2, command2, exclude2]] = pool.map(command_and_feeder,
-                                                   [path1, path2])
+        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:
+          cmd1 = command_and_feeder(path1)
+          cmd2 = command_and_feeder(path2)
+        else:
+          cmd1, cmd2 = results[0], results[1]
+
+        feeder1, command1, excluded1 = cmd1
+        feeder2, command2, excluded2 = cmd2
 
         if not feeder1 or not feeder2:
             assert excluded1 or excluded2

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list