diff options
| author | Adrian Freihofer <adrian.freihofer@gmail.com> | 2023-09-10 17:52:32 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-09-12 12:44:47 +0100 |
| commit | 40fdebda20af3546186cc63e3c2c71dfd2ad6bc0 (patch) | |
| tree | bd0045e06765845599bcf659da57b1db6dff7c23 /meta/lib/oe | |
| parent | 48c80dcb15b31ca5e9899d7a442e489fbc8be00d (diff) | |
| download | poky-40fdebda20af3546186cc63e3c2c71dfd2ad6bc0.tar.gz | |
lib/oe/utils: Refactor to make multiprocess_launch callable without d
This is a preparation for making the strip_execs function callable from
devtool without going via tinfoil and a bitbake server process.
(From OE-Core rev: af8ee73cdef90b83556a7ac5e139a08108706486)
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe')
| -rw-r--r-- | meta/lib/oe/utils.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py index 1658f3555d..a3b1bb1087 100644 --- a/meta/lib/oe/utils.py +++ b/meta/lib/oe/utils.py | |||
| @@ -264,10 +264,17 @@ def execute_pre_post_process(d, cmds): | |||
| 264 | bb.note("Executing %s ..." % cmd) | 264 | bb.note("Executing %s ..." % cmd) |
| 265 | bb.build.exec_func(cmd, d) | 265 | bb.build.exec_func(cmd, d) |
| 266 | 266 | ||
| 267 | # For each item in items, call the function 'target' with item as the first | 267 | def get_bb_number_threads(d): |
| 268 | return int(d.getVar("BB_NUMBER_THREADS") or os.cpu_count() or 1) | ||
| 269 | |||
| 270 | def multiprocess_launch(target, items, d, extraargs=None): | ||
| 271 | max_process = get_bb_number_threads(d) | ||
| 272 | return multiprocess_launch_mp(target, items, max_process, extraargs) | ||
| 273 | |||
| 274 | # For each item in items, call the function 'target' with item as the first | ||
| 268 | # argument, extraargs as the other arguments and handle any exceptions in the | 275 | # argument, extraargs as the other arguments and handle any exceptions in the |
| 269 | # parent thread | 276 | # parent thread |
| 270 | def multiprocess_launch(target, items, d, extraargs=None): | 277 | def multiprocess_launch_mp(target, items, max_process, extraargs=None): |
| 271 | 278 | ||
| 272 | class ProcessLaunch(multiprocessing.Process): | 279 | class ProcessLaunch(multiprocessing.Process): |
| 273 | def __init__(self, *args, **kwargs): | 280 | def __init__(self, *args, **kwargs): |
| @@ -302,7 +309,6 @@ def multiprocess_launch(target, items, d, extraargs=None): | |||
| 302 | self.update() | 309 | self.update() |
| 303 | return self._result | 310 | return self._result |
| 304 | 311 | ||
| 305 | max_process = int(d.getVar("BB_NUMBER_THREADS") or os.cpu_count() or 1) | ||
| 306 | launched = [] | 312 | launched = [] |
| 307 | errors = [] | 313 | errors = [] |
| 308 | results = [] | 314 | results = [] |
