summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2017-07-07 15:42:05 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-07-08 13:29:54 +0100
commit3c602dd4a5adbd40a79224452fc20e1a8641c7a1 (patch)
tree44ce96d2787fd23a3f222dd365daa1fb38ad5e9b /bitbake
parent35846a39614815032e4db0d2f26709983a9802d7 (diff)
downloadpoky-3c602dd4a5adbd40a79224452fc20e1a8641c7a1.tar.gz
bitbake: server/xmlrpc: Add Heartbeat event support
When heartbeat event support was added it was only added to process.py. Add it to server/xmlrpc too. There is duplicated code however since we're likely to combine the server abstractions soon its not worth worrying about now. This ensures the backends have the same event support. [YOCTO #10741] (Bitbake rev: 00bf2e60222767b4dee84fb3f958732a83544e80) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/server/xmlrpc.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py
index d0f5a6d6da..1a475e04ba 100644
--- a/bitbake/lib/bb/server/xmlrpc.py
+++ b/bitbake/lib/bb/server/xmlrpc.py
@@ -227,6 +227,8 @@ class XMLRPCServer(SimpleXMLRPCServer, BaseImplServer):
227 self.idle_timeout = idle_timeout 227 self.idle_timeout = idle_timeout
228 if idle_timeout: 228 if idle_timeout:
229 self.register_idle_function(self.handle_idle_timeout, self) 229 self.register_idle_function(self.handle_idle_timeout, self)
230 self.heartbeat_seconds = 1 # default, BB_HEARTBEAT_EVENT will be checked once we have a datastore.
231 self.next_heartbeat = time.time()
230 232
231 def addcooker(self, cooker): 233 def addcooker(self, cooker):
232 BaseImplServer.addcooker(self, cooker) 234 BaseImplServer.addcooker(self, cooker)
@@ -250,6 +252,15 @@ class XMLRPCServer(SimpleXMLRPCServer, BaseImplServer):
250 return [] 252 return []
251 253
252 def serve_forever(self): 254 def serve_forever(self):
255 heartbeat_event = self.cooker.data.getVar('BB_HEARTBEAT_EVENT')
256 if heartbeat_event:
257 try:
258 self.heartbeat_seconds = float(heartbeat_event)
259 except:
260 # Throwing an exception here causes bitbake to hang.
261 # Just warn about the invalid setting and continue
262 bb.warn('Ignoring invalid BB_HEARTBEAT_EVENT=%s, must be a float specifying seconds.' % heartbeat_event)
263
253 # Start the actual XMLRPC server 264 # Start the actual XMLRPC server
254 bb.cooker.server_main(self.cooker, self._serve_forever) 265 bb.cooker.server_main(self.cooker, self._serve_forever)
255 266
@@ -297,6 +308,21 @@ class XMLRPCServer(SimpleXMLRPCServer, BaseImplServer):
297 # we ignore interrupted calls 308 # we ignore interrupted calls
298 pass 309 pass
299 310
311 # Create new heartbeat event?
312 now = time.time()
313 if now >= self.next_heartbeat:
314 # We might have missed heartbeats. Just trigger once in
315 # that case and continue after the usual delay.
316 self.next_heartbeat += self.heartbeat_seconds
317 if self.next_heartbeat <= now:
318 self.next_heartbeat = now + self.heartbeat_seconds
319 heartbeat = bb.event.HeartbeatEvent(now)
320 bb.event.fire(heartbeat, self.cooker.data)
321 if nextsleep and now + nextsleep > self.next_heartbeat:
322 # Shorten timeout so that we we wake up in time for
323 # the heartbeat.
324 nextsleep = self.next_heartbeat - now
325
300 # Tell idle functions we're exiting 326 # Tell idle functions we're exiting
301 for function, data in list(self._idlefuns.items()): 327 for function, data in list(self._idlefuns.items()):
302 try: 328 try: