summaryrefslogtreecommitdiffstats
path: root/meta/classes/package_deb.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2018-07-19 20:32:44 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-07-24 11:52:27 +0100
commit3fa835d9bcc6802390cefda266b25856178c553f (patch)
tree42e4952c2b7bae4903255f4f0aff230a32b20d93 /meta/classes/package_deb.bbclass
parent2245a94bb87ec1e13c542f2074d4b9e531ffeaf1 (diff)
downloadpoky-3fa835d9bcc6802390cefda266b25856178c553f.tar.gz
package_ipk|deb: Use oe.utils.multiprocess_launch
The current code had broken exception handling due to the use of a "traceback" variable as well as an import. Use the new library code for this instead which reduces code duplication and has fixed/improved exception handling. The chdir code can be dropped since any directory changes are in other processes now so there is no need for it here and the code no longer changes directory. (From OE-Core rev: bcd47389f4b1fc69d2bb4da01933bfa1fdcae092) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/package_deb.bbclass')
-rw-r--r--meta/classes/package_deb.bbclass51
1 files changed, 1 insertions, 50 deletions
diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass
index 2e8d17d3c7..6f81591653 100644
--- a/meta/classes/package_deb.bbclass
+++ b/meta/classes/package_deb.bbclass
@@ -41,32 +41,6 @@ def debian_arch_map(arch, tune):
41 return arch 41 return arch
42 42
43python do_package_deb () { 43python do_package_deb () {
44
45 import multiprocessing
46 import traceback
47
48 class DebianWritePkgProcess(multiprocessing.Process):
49 def __init__(self, *args, **kwargs):
50 multiprocessing.Process.__init__(self, *args, **kwargs)
51 self._pconn, self._cconn = multiprocessing.Pipe()
52 self._exception = None
53
54 def run(self):
55 try:
56 multiprocessing.Process.run(self)
57 self._cconn.send(None)
58 except Exception as e:
59 tb = traceback.format_exc()
60 self._cconn.send((e, tb))
61
62 @property
63 def exception(self):
64 if self._pconn.poll():
65 self._exception = self._pconn.recv()
66 return self._exception
67
68 oldcwd = os.getcwd()
69
70 packages = d.getVar('PACKAGES') 44 packages = d.getVar('PACKAGES')
71 if not packages: 45 if not packages:
72 bb.debug(1, "PACKAGES not defined, nothing to package") 46 bb.debug(1, "PACKAGES not defined, nothing to package")
@@ -76,30 +50,7 @@ python do_package_deb () {
76 if os.access(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN"),os.R_OK): 50 if os.access(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN"),os.R_OK):
77 os.unlink(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN")) 51 os.unlink(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN"))
78 52
79 max_process = int(d.getVar("BB_NUMBER_THREADS") or os.cpu_count() or 1) 53 oe.utils.multiprocess_launch(deb_write_pkg, packages.split(), d, extraargs=(d,))
80 launched = []
81 error = None
82 pkgs = packages.split()
83 while not error and pkgs:
84 if len(launched) < max_process:
85 p = DebianWritePkgProcess(target=deb_write_pkg, args=(pkgs.pop(), d))
86 p.start()
87 launched.append(p)
88 for q in launched:
89 # The finished processes are joined when calling is_alive()
90 if not q.is_alive():
91 launched.remove(q)
92 if q.exception:
93 error, traceback = q.exception
94 break
95
96 for p in launched:
97 p.join()
98
99 os.chdir(oldcwd)
100
101 if error:
102 raise error
103} 54}
104do_package_deb[vardeps] += "deb_write_pkg" 55do_package_deb[vardeps] += "deb_write_pkg"
105do_package_deb[vardepsexclude] = "BB_NUMBER_THREADS" 56do_package_deb[vardepsexclude] = "BB_NUMBER_THREADS"