summaryrefslogtreecommitdiffstats
path: root/meta/classes/package_deb.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/package_deb.bbclass')
-rw-r--r--meta/classes/package_deb.bbclass36
1 files changed, 33 insertions, 3 deletions
diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass
index 30605344f4..5d297939b6 100644
--- a/meta/classes/package_deb.bbclass
+++ b/meta/classes/package_deb.bbclass
@@ -41,7 +41,29 @@ def debian_arch_map(arch, tune):
41 return arch 41 return arch
42 42
43python do_package_deb () { 43python do_package_deb () {
44 from multiprocessing import Process 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
45 67
46 oldcwd = os.getcwd() 68 oldcwd = os.getcwd()
47 69
@@ -56,20 +78,28 @@ python do_package_deb () {
56 78
57 max_process = int(d.getVar("BB_NUMBER_THREADS") or os.cpu_count() or 1) 79 max_process = int(d.getVar("BB_NUMBER_THREADS") or os.cpu_count() or 1)
58 launched = [] 80 launched = []
81 error = None
59 pkgs = packages.split() 82 pkgs = packages.split()
60 while pkgs: 83 while not error and pkgs:
61 if len(launched) < max_process: 84 if len(launched) < max_process:
62 p = Process(target=deb_write_pkg, args=(pkgs.pop(), d)) 85 p = DebianWritePkgProcess(target=deb_write_pkg, args=(pkgs.pop(), d))
63 p.start() 86 p.start()
64 launched.append(p) 87 launched.append(p)
65 for q in launched: 88 for q in launched:
66 # The finished processes are joined when calling is_alive() 89 # The finished processes are joined when calling is_alive()
67 if not q.is_alive(): 90 if not q.is_alive():
68 launched.remove(q) 91 launched.remove(q)
92 if q.exception:
93 error, traceback = q.exception
94 break
95
69 for p in launched: 96 for p in launched:
70 p.join() 97 p.join()
71 98
72 os.chdir(oldcwd) 99 os.chdir(oldcwd)
100
101 if error:
102 raise error
73} 103}
74do_package_deb[vardeps] += "deb_write_pkg" 104do_package_deb[vardeps] += "deb_write_pkg"
75do_package_deb[vardepsexclude] = "BB_NUMBER_THREADS" 105do_package_deb[vardepsexclude] = "BB_NUMBER_THREADS"