summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/command.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-12-29 14:56:14 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-12-31 17:05:17 +0000
commitc4ecfc4dc5511a23e12ed68eb140a67fd4181127 (patch)
tree46586a8cfdac78f493d58a835b1d6009b8d13c4d /bitbake/lib/bb/command.py
parentff2d778f6d33a4e48406f7bbc7fdbc4e95113069 (diff)
downloadpoky-c4ecfc4dc5511a23e12ed68eb140a67fd4181127.tar.gz
bitbake: server/process: Improve idle loop exit code
When idle handlers want to exit, returning "False" isn't very clear and also causes challenges with the ordering of the removing the idle handler and marking that no async command is running. Use a specific class to signal the exit condition allowing clearer code and allowing the async command to be cleared after the handler has been removed, reducing any opportunity for races. (Bitbake rev: 102e8d0d4c5c0dd8c7ba09ad26589deec77e4308) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/command.py')
-rw-r--r--bitbake/lib/bb/command.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index cbac07f516..732327d84d 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -128,22 +128,19 @@ class Command:
128 else: 128 else:
129 return False 129 return False
130 except KeyboardInterrupt as exc: 130 except KeyboardInterrupt as exc:
131 self.finishAsyncCommand("Interrupted") 131 return bb.server.process.idleFinish("Interrupted")
132 return False
133 except SystemExit as exc: 132 except SystemExit as exc:
134 arg = exc.args[0] 133 arg = exc.args[0]
135 if isinstance(arg, str): 134 if isinstance(arg, str):
136 self.finishAsyncCommand(arg) 135 return bb.server.process.idleFinish(arg)
137 else: 136 else:
138 self.finishAsyncCommand("Exited with %s" % arg) 137 return bb.server.process.idleFinish("Exited with %s" % arg)
139 return False
140 except Exception as exc: 138 except Exception as exc:
141 import traceback 139 import traceback
142 if isinstance(exc, bb.BBHandledException): 140 if isinstance(exc, bb.BBHandledException):
143 self.finishAsyncCommand("") 141 return bb.server.process.idleFinish("")
144 else: 142 else:
145 self.finishAsyncCommand(traceback.format_exc()) 143 return bb.server.process.idleFinish(traceback.format_exc())
146 return False
147 144
148 def finishAsyncCommand(self, msg=None, code=None): 145 def finishAsyncCommand(self, msg=None, code=None):
149 if msg or msg == "": 146 if msg or msg == "":