diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-03-26 18:14:44 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-03-30 13:04:07 +0100 |
commit | ae89e23696de2f27c00ae00922933395171de5d5 (patch) | |
tree | 701046ab71ea2c2c29e9ec4ad4d49975f4091e53 | |
parent | b4a157b2fe2fb481ffa40e0f32659d05dd6320c2 (diff) | |
download | bitbake-ae89e23696de2f27c00ae00922933395171de5d5.tar.gz |
cooker: Fix exception handling in parsers
We shouldn't be generating exception inside a generator. Rearrange the
code to improve the handling of this. Also fix the misconverted code
from when multiconfig was added and pass the exception as "result".
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/bb/cooker.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py index eac956aa9..c4d720a6b 100644 --- a/lib/bb/cooker.py +++ b/lib/bb/cooker.py @@ -2087,12 +2087,12 @@ class Parser(multiprocessing.Process): tb = sys.exc_info()[2] exc.recipe = filename exc.traceback = list(bb.exceptions.extract_traceback(tb, context=3)) - return True, exc + return True, None, exc # Need to turn BaseExceptions into Exceptions here so we gracefully shutdown # and for example a worker thread doesn't just exit on its own in response to # a SystemExit event for example. except BaseException as exc: - return True, ParsingFailure(exc, filename) + return True, None, ParsingFailure(exc, filename) finally: bb.event.LogHandler.filter = origfilter @@ -2252,11 +2252,7 @@ class CookerParser(object): pass else: empty = False - value = result[1] - if isinstance(value, BaseException): - raise value - else: - yield result + yield result if not (self.parsed >= self.toparse): raise bb.parse.ParseError("Not all recipes parsed, parser thread killed/died? Exiting.", None) @@ -2267,6 +2263,9 @@ class CookerParser(object): parsed = None try: parsed, mc, result = next(self.results) + if isinstance(result, BaseException): + # Turn exceptions back into exceptions + raise result except StopIteration: self.shutdown() return False |