summaryrefslogtreecommitdiffstats
path: root/lib/bb/server/process.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bb/server/process.py')
-rw-r--r--lib/bb/server/process.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py
index 982fcf71c..1654faf92 100644
--- a/lib/bb/server/process.py
+++ b/lib/bb/server/process.py
@@ -92,6 +92,8 @@ class ProcessServer(Process, BaseImplServer):
self.event = EventAdapter(event_queue)
self.featurelist = featurelist
self.quit = False
+ self.heartbeat_seconds = 1 # default, BB_HEARTBEAT_EVENT will be checked once we have a datastore.
+ self.next_heartbeat = time.time()
self.quitin, self.quitout = Pipe()
self.event_handle = multiprocessing.Value("i")
@@ -101,6 +103,14 @@ class ProcessServer(Process, BaseImplServer):
self.event_queue.put(event)
self.event_handle.value = bb.event.register_UIHhandler(self, True)
+ heartbeat_event = self.cooker.data.getVar('BB_HEARTBEAT_EVENT', True)
+ if heartbeat_event:
+ try:
+ self.heartbeat_seconds = float(heartbeat_event)
+ except:
+ # Throwing an exception here causes bitbake to hang.
+ # Just warn about the invalid setting and continue
+ bb.warn('Ignoring invalid BB_HEARTBEAT_EVENT=%s, must be a float specifying seconds.' % heartbeat_event)
bb.cooker.server_main(self.cooker, self.main)
def main(self):
@@ -160,6 +170,21 @@ class ProcessServer(Process, BaseImplServer):
del self._idlefuns[function]
self.quit = True
+ # Create new heartbeat event?
+ now = time.time()
+ if now >= self.next_heartbeat:
+ # We might have missed heartbeats. Just trigger once in
+ # that case and continue after the usual delay.
+ self.next_heartbeat += self.heartbeat_seconds
+ if self.next_heartbeat <= now:
+ self.next_heartbeat = now + self.heartbeat_seconds
+ heartbeat = bb.event.HeartbeatEvent(now)
+ bb.event.fire(heartbeat, self.cooker.data)
+ if nextsleep and now + nextsleep > self.next_heartbeat:
+ # Shorten timeout so that we we wake up in time for
+ # the heartbeat.
+ nextsleep = self.next_heartbeat - now
+
if nextsleep is not None:
select.select(fds,[],[],nextsleep)