diff options
-rw-r--r-- | meta/classes/package_deb.bbclass | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass index 04b91970c7..23b449cbe0 100644 --- a/meta/classes/package_deb.bbclass +++ b/meta/classes/package_deb.bbclass | |||
@@ -51,6 +51,8 @@ def debian_arch_map(arch, tune): | |||
51 | # INSTALL_TASK_DEB - task name | 51 | # INSTALL_TASK_DEB - task name |
52 | 52 | ||
53 | python do_package_deb () { | 53 | python do_package_deb () { |
54 | from multiprocessing import Process | ||
55 | |||
54 | oldcwd = os.getcwd() | 56 | oldcwd = os.getcwd() |
55 | 57 | ||
56 | packages = d.getVar('PACKAGES') | 58 | packages = d.getVar('PACKAGES') |
@@ -62,11 +64,25 @@ python do_package_deb () { | |||
62 | if os.access(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN"),os.R_OK): | 64 | if os.access(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN"),os.R_OK): |
63 | os.unlink(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN")) | 65 | os.unlink(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN")) |
64 | 66 | ||
65 | for pkg in packages.split(): | 67 | max_process = int(d.getVar("BB_NUMBER_THREADS") or os.cpu_count() or 1) |
66 | deb_write_pkg(pkg, d) | 68 | launched = [] |
69 | pkgs = packages.split() | ||
70 | while pkgs: | ||
71 | if len(launched) < max_process: | ||
72 | p = Process(target=deb_write_pkg, args=(pkgs.pop(), d)) | ||
73 | p.start() | ||
74 | launched.append(p) | ||
75 | for q in launched: | ||
76 | # The finished processes are joined when calling is_alive() | ||
77 | if not q.is_alive(): | ||
78 | launched.remove(q) | ||
79 | for p in launched: | ||
80 | p.join() | ||
67 | 81 | ||
68 | os.chdir(oldcwd) | 82 | os.chdir(oldcwd) |
69 | } | 83 | } |
84 | do_package_deb[vardeps] += "deb_write_pkg" | ||
85 | do_package_deb[vardepsexclude] = "BB_NUMBER_THREADS" | ||
70 | 86 | ||
71 | def deb_write_pkg(pkg, d): | 87 | def deb_write_pkg(pkg, d): |
72 | import re, copy | 88 | import re, copy |