[diffoscope] 04/06: parallel: comparison_pool: added map method

Juliana Oliveira jwnx-guest at moszumanska.debian.org
Tue Jan 9 05:04:26 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 4929388b20f44fee758ab3dde8d9d74c59091bd8
Author: Juliana Oliveira <juliana.orod at gmail.com>
Date:   Tue Jan 9 00:58:32 2018 -0200

    parallel: comparison_pool: added map method
---
 diffoscope/parallel/__init__.py        |  0
 diffoscope/parallel/comparison_pool.py | 17 +++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/diffoscope/parallel/__init__.py b/diffoscope/parallel/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/diffoscope/parallel/comparison_pool.py b/diffoscope/parallel/comparison_pool.py
index bbc8804..43c7594 100644
--- a/diffoscope/parallel/comparison_pool.py
+++ b/diffoscope/parallel/comparison_pool.py
@@ -3,6 +3,7 @@ import dill
 
 from pathos.multiprocessing import ProcessingPool as Pool
 from diffoscope.config import Config
+from diffoscope.parallel.thread_manager import ThreadManager
 
 
 logger = logging.getLogger(__name__)
@@ -16,4 +17,20 @@ class ComparisonPool(object):
     logger.debug("ComparisonPool initialized. Pool size: %d", self._pool_size)
 
 
+  def map(self, fun, args=[]):
+    logger.debug("Invoking parallel map for function %s", fun)
+
+    threads = ThreadManager()
+
+    for arg in args:
+      threads.new(fun, arg)
+
+    threads.join()
+
+    while not threads.ready():
+      time.sleep(0.5)
+
+    return threads.result()
+
+
 pool = ComparisonPool()

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


More information about the diffoscope mailing list