bitbake: knotty: Improve shutdown handling

There are three levels of shutdown, the initial "wait for current tasks",
then "stop current tasks" and "exit now". Change the code so that we don't
instantly exit after "stop current tasks" but allow the events to come
through from the server first. The new shutdown level allows that to then
be broken out of too.

(Bitbake rev: af38345b91cfc8a6bb5c38f5753255e7635bfe2b)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2023-01-11 17:43:30 +00:00
parent 92c0dba456
commit 3a439f94ab

View File

@@ -631,7 +631,12 @@ def main(server, eventHandler, params, tf = TerminalFilter):
termfilter = tf(main, helper, console_handlers, params.options.quiet)
atexit.register(termfilter.finish)
while main.shutdown < 2:
# shutdown levels
# 0 - normal operation
# 1 - no new task execution, let current running tasks finish
# 2 - interrupting currently executing tasks
# 3 - we're done, exit
while main.shutdown < 3:
try:
if (lastprint + printinterval) <= time.time():
termfilter.keepAlive(printinterval)
@@ -644,7 +649,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
termfilter.clearFooter()
print("No reply after pinging server (%s, %s), exiting." % (str(error), str(ret)))
return_value = 3
main.shutdown = 2
main.shutdown = 3
lastevent = time.time()
if not parseprogress:
termfilter.updateFooter()
@@ -756,15 +761,15 @@ def main(server, eventHandler, params, tf = TerminalFilter):
if event.error:
errors = errors + 1
logger.error(str(event))
main.shutdown = 2
main.shutdown = 3
continue
if isinstance(event, bb.command.CommandExit):
if not return_value:
return_value = event.exitcode
main.shutdown = 2
main.shutdown = 3
continue
if isinstance(event, (bb.command.CommandCompleted, bb.cooker.CookerExit)):
main.shutdown = 2
main.shutdown = 3
continue
if isinstance(event, bb.event.MultipleProviders):
logger.info(str(event))