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:05:03 +0100 |
| commit | 99f9b9b439d483f0d120b7590eb8b5e7f78b91e3 (patch) | |
| tree | 83337222725a3fd3feb43e82e29d15e463ab5dd4 /bitbake/lib | |
| parent | 259c30621f8b2072fc4878c210d2ddadbdea91e1 (diff) | |
| download | poky-99f9b9b439d483f0d120b7590eb8b5e7f78b91e3.tar.gz | |
bitbake: 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".
(Bitbake rev: ae89e23696de2f27c00ae00922933395171de5d5)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
| -rw-r--r-- | bitbake/lib/bb/cooker.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index eac956aa97..c4d720a6b6 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
| @@ -2087,12 +2087,12 @@ class Parser(multiprocessing.Process): | |||
| 2087 | tb = sys.exc_info()[2] | 2087 | tb = sys.exc_info()[2] |
| 2088 | exc.recipe = filename | 2088 | exc.recipe = filename |
| 2089 | exc.traceback = list(bb.exceptions.extract_traceback(tb, context=3)) | 2089 | exc.traceback = list(bb.exceptions.extract_traceback(tb, context=3)) |
| 2090 | return True, exc | 2090 | return True, None, exc |
| 2091 | # Need to turn BaseExceptions into Exceptions here so we gracefully shutdown | 2091 | # Need to turn BaseExceptions into Exceptions here so we gracefully shutdown |
| 2092 | # and for example a worker thread doesn't just exit on its own in response to | 2092 | # and for example a worker thread doesn't just exit on its own in response to |
| 2093 | # a SystemExit event for example. | 2093 | # a SystemExit event for example. |
| 2094 | except BaseException as exc: | 2094 | except BaseException as exc: |
| 2095 | return True, ParsingFailure(exc, filename) | 2095 | return True, None, ParsingFailure(exc, filename) |
| 2096 | finally: | 2096 | finally: |
| 2097 | bb.event.LogHandler.filter = origfilter | 2097 | bb.event.LogHandler.filter = origfilter |
| 2098 | 2098 | ||
| @@ -2252,11 +2252,7 @@ class CookerParser(object): | |||
| 2252 | pass | 2252 | pass |
| 2253 | else: | 2253 | else: |
| 2254 | empty = False | 2254 | empty = False |
| 2255 | value = result[1] | 2255 | yield result |
| 2256 | if isinstance(value, BaseException): | ||
| 2257 | raise value | ||
| 2258 | else: | ||
| 2259 | yield result | ||
| 2260 | 2256 | ||
| 2261 | if not (self.parsed >= self.toparse): | 2257 | if not (self.parsed >= self.toparse): |
| 2262 | raise bb.parse.ParseError("Not all recipes parsed, parser thread killed/died? Exiting.", None) | 2258 | raise bb.parse.ParseError("Not all recipes parsed, parser thread killed/died? Exiting.", None) |
| @@ -2267,6 +2263,9 @@ class CookerParser(object): | |||
| 2267 | parsed = None | 2263 | parsed = None |
| 2268 | try: | 2264 | try: |
| 2269 | parsed, mc, result = next(self.results) | 2265 | parsed, mc, result = next(self.results) |
| 2266 | if isinstance(result, BaseException): | ||
| 2267 | # Turn exceptions back into exceptions | ||
| 2268 | raise result | ||
| 2270 | except StopIteration: | 2269 | except StopIteration: |
| 2271 | self.shutdown() | 2270 | self.shutdown() |
| 2272 | return False | 2271 | return False |
