diff options
Diffstat (limited to 'meta/classes/package_deb.bbclass')
-rw-r--r-- | meta/classes/package_deb.bbclass | 51 |
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 | ||
43 | python do_package_deb () { | 43 | python 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 | } |
104 | do_package_deb[vardeps] += "deb_write_pkg" | 55 | do_package_deb[vardeps] += "deb_write_pkg" |
105 | do_package_deb[vardepsexclude] = "BB_NUMBER_THREADS" | 56 | do_package_deb[vardepsexclude] = "BB_NUMBER_THREADS" |