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>
This commit is contained in:
Richard Purdie
2022-12-29 14:56:14 +00:00
parent ff2d778f6d
commit c4ecfc4dc5
3 changed files with 20 additions and 17 deletions

View File

@@ -128,22 +128,19 @@ class Command:
else:
return False
except KeyboardInterrupt as exc:
self.finishAsyncCommand("Interrupted")
return False
return bb.server.process.idleFinish("Interrupted")
except SystemExit as exc:
arg = exc.args[0]
if isinstance(arg, str):
self.finishAsyncCommand(arg)
return bb.server.process.idleFinish(arg)
else:
self.finishAsyncCommand("Exited with %s" % arg)
return False
return bb.server.process.idleFinish("Exited with %s" % arg)
except Exception as exc:
import traceback
if isinstance(exc, bb.BBHandledException):
self.finishAsyncCommand("")
return bb.server.process.idleFinish("")
else:
self.finishAsyncCommand(traceback.format_exc())
return False
return bb.server.process.idleFinish(traceback.format_exc())
def finishAsyncCommand(self, msg=None, code=None):
if msg or msg == "":