1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-02 01:19:52 +00:00

bitbake: event/cooker/runqueue: Add ability to interrupt longer running code

Bitbake is now able to understand when a UI wants it to stop the current
processing. There are some long running functions which currently have no
mechanism to interrupt them however.

This patch adds a call, bb.event.check_for_interrupts(d) which can be
placed in long running code and allows an internal state flag within
bitbake to be checked. If set, that flag will trigger an exit.

This means that Ctrl+C can be made to work in a variety of places where
it currently would not.

Long running event handlers in OE-Core can also then benefit from this
new approach with the addition of the function call as well.

(Bitbake rev: b7ed7e9a815c4e10447fd499508be3dbb47f06e8)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2023-02-22 13:31:34 +00:00
parent 906657e9be
commit 42c92cbc83
3 changed files with 30 additions and 0 deletions
+4
View File
@@ -345,6 +345,7 @@ class BBCooker:
elif signum == signal.SIGHUP:
bb.warn("Cooker received SIGHUP, shutting down...")
self.state = state.forceshutdown
bb.event._should_exit.set()
def setFeatures(self, features):
# we only accept a new feature set if we're in state initial, so we can reset without problems
@@ -1520,6 +1521,7 @@ class BBCooker:
msg = None
interrupted = 0
if halt or self.state == state.forceshutdown:
bb.event._should_exit.set()
rq.finish_runqueue(True)
msg = "Forced shutdown"
interrupted = 2
@@ -1760,6 +1762,7 @@ class BBCooker:
self.state = state.forceshutdown
else:
self.state = state.shutdown
bb.event._should_exit.set()
if self.parser:
self.parser.shutdown(clean=False)
@@ -1770,6 +1773,7 @@ class BBCooker:
self.parser.shutdown(clean=False)
self.parser.final_cleanup()
self.state = state.initial
bb.event._should_exit.clear()
def reset(self):
if hasattr(bb.parse, "siggen"):