diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-03-26 18:27:28 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-03-30 13:04:07 +0100 |
commit | e1ba2a69f1fc02f01a851bce20b1badf0b991f03 (patch) | |
tree | 837ff31fe51358499c458e07a89f0b47eabe9acf | |
parent | a2cde38311a51112dca5e7bb4e7feaf4e6a281b3 (diff) | |
download | bitbake-e1ba2a69f1fc02f01a851bce20b1badf0b991f03.tar.gz |
cooker: Improve exception handling in parsing process
If an exception occurs in the parsing process, ensure the cleanup
is called via all codepaths using a try/finally.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/bb/cooker.py | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py index fb71a968f..2264b18c5 100644 --- a/lib/bb/cooker.py +++ b/lib/bb/cooker.py @@ -2041,32 +2041,32 @@ class Parser(multiprocessing.Process): self.init() pending = [] - while True: - try: - self.quit.get_nowait() - except queue.Empty: - pass - else: - self.results.close() - self.results.join_thread() - break - - if pending: - result = pending.pop() - else: + try: + while True: try: - job = self.jobs.pop() - except IndexError: - self.results.close() - self.results.join_thread() + self.quit.get_nowait() + except queue.Empty: + pass + else: break - result = self.parse(*job) - # Clear the siggen cache after parsing to control memory usage, its huge - bb.parse.siggen.postparsing_clean_cache() - try: - self.results.put(result, timeout=0.25) - except queue.Full: - pending.append(result) + + if pending: + result = pending.pop() + else: + try: + job = self.jobs.pop() + except IndexError: + break + result = self.parse(*job) + # Clear the siggen cache after parsing to control memory usage, its huge + bb.parse.siggen.postparsing_clean_cache() + try: + self.results.put(result, timeout=0.25) + except queue.Full: + pending.append(result) + finally: + self.results.close() + self.results.join_thread() def parse(self, mc, cache, filename, appends): try: |