[projects/git-slug: 5/9] Parallelize initpackage operation.

glen glen at pld-linux.org
Mon Sep 21 21:41:07 CEST 2015


commit 3482f3141eb1ecc9cc44d7b6d5af359960a49e73
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Fri Nov 28 12:13:27 2014 +0100

    Parallelize initpackage operation.

 slug.py | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/slug.py b/slug.py
index fa8fd89..914e894 100755
--- a/slug.py
+++ b/slug.py
@@ -108,15 +108,25 @@ def fetch_package(gitrepo, ref2fetch, options):
 def fetch_packages(options, return_all=False):
     refs = getrefs(options.branch, options.repopattern)
     print('Read remotes data')
+    pkgs_new = []
+    if options.newpkgs:
+        for pkgdir in sorted(refs.heads):
+            gitdir = os.path.join(options.packagesdir, pkgdir, '.git')
+            if not os.path.isdir(gitdir):
+                pkgs_new.append(pkgdir)
+
+        pool = WorkerPool(options.jobs, pool_worker_init)
+        try:
+            pool.starmap(initpackage, zip(pkgs_new, [options] * len(pkgs_new)))
+        except KeyboardInterrupt:
+            pool.terminate()
+        else:
+            pool.close()
+        pool.join()
+
     args = []
     for pkgdir in sorted(refs.heads):
-        gitdir = os.path.join(options.packagesdir, pkgdir, '.git')
-        if not os.path.isdir(gitdir):
-            if options.newpkgs:
-                gitrepo = initpackage(pkgdir, options)
-            else:
-                continue
-        elif options.omitexisting:
+        if options.omitexisting and pkgdir not in pkgs_new:
             continue
         else:
             gitrepo = GitRepo(os.path.join(options.packagesdir, pkgdir))
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/d9fdf7d60e5aea39f9ac7065a09a645261fc712b



More information about the pld-cvs-commit mailing list