aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2023-01-11 17:43:30 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-01-11 23:14:29 +0000
commitaf38345b91cfc8a6bb5c38f5753255e7635bfe2b (patch)
treee9739d6e922c766dbad498a2331b397fe1d5295f
parent32da768ae67cfe0b2d154ce4667a7cfdfa5bf4b0 (diff)
downloadbitbake-contrib-af38345b91cfc8a6bb5c38f5753255e7635bfe2b.tar.gz
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. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/ui/knotty.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py
index 7370a1adf..431baa15e 100644
--- a/lib/bb/ui/knotty.py
+++ b/lib/bb/ui/knotty.py
@@ -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))