[oe-commits] [openembedded-core] 02/10: package_deb: Enable multithreaded package creation

git at git.openembedded.org git at git.openembedded.org
Fri Jun 16 09:58:53 UTC 2017


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit dd540fba6c65fb74df014f5d9d2965078314a790
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
AuthorDate: Fri Mar 31 15:06:39 2017 +0100

    package_deb: Enable multithreaded package creation
    
    Allow the creation of debs to happen in parallel, making best use of resources
    on multiprocessor systems.
    
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/classes/package_deb.bbclass | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass
index 04b9197..23b449c 100644
--- a/meta/classes/package_deb.bbclass
+++ b/meta/classes/package_deb.bbclass
@@ -51,6 +51,8 @@ def debian_arch_map(arch, tune):
 # INSTALL_TASK_DEB - task name
 
 python do_package_deb () {
+    from multiprocessing import Process
+
     oldcwd = os.getcwd()
 
     packages = d.getVar('PACKAGES')
@@ -62,11 +64,25 @@ python do_package_deb () {
     if os.access(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN"),os.R_OK):
         os.unlink(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN"))
 
-    for pkg in packages.split():
-        deb_write_pkg(pkg, d)
+    max_process = int(d.getVar("BB_NUMBER_THREADS") or os.cpu_count() or 1)
+    launched = []
+    pkgs = packages.split()
+    while pkgs:
+        if len(launched) < max_process:
+            p = Process(target=deb_write_pkg, args=(pkgs.pop(), d))
+            p.start()
+            launched.append(p)
+        for q in launched:
+            # The finished processes are joined when calling is_alive()
+            if not q.is_alive():
+                launched.remove(q)
+    for p in launched:
+        p.join()
 
     os.chdir(oldcwd)
 }
+do_package_deb[vardeps] += "deb_write_pkg"
+do_package_deb[vardepsexclude] = "BB_NUMBER_THREADS"
 
 def deb_write_pkg(pkg, d):
     import re, copy

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list