summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cooker.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2023-02-22 13:31:34 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-02-23 12:12:18 +0000
commit42c92cbc83a56249203aeb23fe524f9b4eebbdf9 (patch)
treeb9c4dbdaacd51acdf564e684712db7ab613f1d52 /bitbake/lib/bb/cooker.py
parent906657e9beef9a256b642ebb9857036710c24f62 (diff)
downloadpoky-42c92cbc83a56249203aeb23fe524f9b4eebbdf9.tar.gz
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>
Diffstat (limited to 'bitbake/lib/bb/cooker.py')
-rw-r--r--bitbake/lib/bb/cooker.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index b673fe10ee..c631ec7e6d 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -345,6 +345,7 @@ class BBCooker:
345 elif signum == signal.SIGHUP: 345 elif signum == signal.SIGHUP:
346 bb.warn("Cooker received SIGHUP, shutting down...") 346 bb.warn("Cooker received SIGHUP, shutting down...")
347 self.state = state.forceshutdown 347 self.state = state.forceshutdown
348 bb.event._should_exit.set()
348 349
349 def setFeatures(self, features): 350 def setFeatures(self, features):
350 # we only accept a new feature set if we're in state initial, so we can reset without problems 351 # 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:
1520 msg = None 1521 msg = None
1521 interrupted = 0 1522 interrupted = 0
1522 if halt or self.state == state.forceshutdown: 1523 if halt or self.state == state.forceshutdown:
1524 bb.event._should_exit.set()
1523 rq.finish_runqueue(True) 1525 rq.finish_runqueue(True)
1524 msg = "Forced shutdown" 1526 msg = "Forced shutdown"
1525 interrupted = 2 1527 interrupted = 2
@@ -1760,6 +1762,7 @@ class BBCooker:
1760 self.state = state.forceshutdown 1762 self.state = state.forceshutdown
1761 else: 1763 else:
1762 self.state = state.shutdown 1764 self.state = state.shutdown
1765 bb.event._should_exit.set()
1763 1766
1764 if self.parser: 1767 if self.parser:
1765 self.parser.shutdown(clean=False) 1768 self.parser.shutdown(clean=False)
@@ -1770,6 +1773,7 @@ class BBCooker:
1770 self.parser.shutdown(clean=False) 1773 self.parser.shutdown(clean=False)
1771 self.parser.final_cleanup() 1774 self.parser.final_cleanup()
1772 self.state = state.initial 1775 self.state = state.initial
1776 bb.event._should_exit.clear()
1773 1777
1774 def reset(self): 1778 def reset(self):
1775 if hasattr(bb.parse, "siggen"): 1779 if hasattr(bb.parse, "siggen"):