summaryrefslogtreecommitdiffstats
path: root/meta/classes/package_ipk.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_ipk.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_ipk.bbclass')
-rw-r--r--meta/classes/package_ipk.bbclass51
1 files changed, 1 insertions, 50 deletions
diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass
index a0b34fa7a5..5eb910ca31 100644
--- a/meta/classes/package_ipk.bbclass
+++ b/meta/classes/package_ipk.bbclass
@@ -17,32 +17,6 @@ OPKG_ARGS += "${@['', '--add-exclude ' + ' --add-exclude '.join((d.getVar('PACKA
17OPKGLIBDIR = "${localstatedir}/lib" 17OPKGLIBDIR = "${localstatedir}/lib"
18 18
19python do_package_ipk () { 19python do_package_ipk () {
20 import multiprocessing
21 import traceback
22
23 class IPKWritePkgProcess(multiprocessing.Process):
24 def __init__(self, *args, **kwargs):
25 multiprocessing.Process.__init__(self, *args, **kwargs)
26 self._pconn, self._cconn = multiprocessing.Pipe()
27 self._exception = None
28
29 def run(self):
30 try:
31 multiprocessing.Process.run(self)
32 self._cconn.send(None)
33 except Exception as e:
34 tb = traceback.format_exc()
35 self._cconn.send((e, tb))
36
37 @property
38 def exception(self):
39 if self._pconn.poll():
40 self._exception = self._pconn.recv()
41 return self._exception
42
43
44 oldcwd = os.getcwd()
45
46 workdir = d.getVar('WORKDIR') 20 workdir = d.getVar('WORKDIR')
47 outdir = d.getVar('PKGWRITEDIRIPK') 21 outdir = d.getVar('PKGWRITEDIRIPK')
48 tmpdir = d.getVar('TMPDIR') 22 tmpdir = d.getVar('TMPDIR')
@@ -61,30 +35,7 @@ python do_package_ipk () {
61 if os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"), os.R_OK): 35 if os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"), os.R_OK):
62 os.unlink(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN")) 36 os.unlink(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"))
63 37
64 max_process = int(d.getVar("BB_NUMBER_THREADS") or os.cpu_count() or 1) 38 oe.utils.multiprocess_launch(ipk_write_pkg, packages.split(), d, extraargs=(d,))
65 launched = []
66 error = None
67 pkgs = packages.split()
68 while not error and pkgs:
69 if len(launched) < max_process:
70 p = IPKWritePkgProcess(target=ipk_write_pkg, args=(pkgs.pop(), d))
71 p.start()
72 launched.append(p)
73 for q in launched:
74 # The finished processes are joined when calling is_alive()
75 if not q.is_alive():
76 launched.remove(q)
77 if q.exception:
78 error, traceback = q.exception
79 break
80
81 for p in launched:
82 p.join()
83
84 os.chdir(oldcwd)
85
86 if error:
87 raise error
88} 39}
89do_package_ipk[vardeps] += "ipk_write_pkg" 40do_package_ipk[vardeps] += "ipk_write_pkg"
90do_package_ipk[vardepsexclude] = "BB_NUMBER_THREADS" 41do_package_ipk[vardepsexclude] = "BB_NUMBER_THREADS"