summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2013-05-31 12:06:47 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-06-07 14:13:18 +0100
commitf549cdd712939990531562b308e2dcea88deba40 (patch)
tree762163d40a6fc649d9a1cf2b9b2a773f8cd2e96f /bitbake/lib
parent748e3c13c80f698f8396bbc55e42ac3ee6a2a81e (diff)
downloadpoky-f549cdd712939990531562b308e2dcea88deba40.tar.gz
bitbake: xmlrpc: Allow server to remain memory resident
This patch enables the XMLRPC server to remain resident in memory after a task is run, and to accept a new controlling client. To check the server after task completion, do lsof bitbake.lock in the build directory. Kill the server with kill. (Bitbake rev: e823e1f0675ff3794eb39ef0b4df2d7a220f4013) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/server/xmlrpc.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py
index 2747ed8bf8..0b51ebd20f 100644
--- a/bitbake/lib/bb/server/xmlrpc.py
+++ b/bitbake/lib/bb/server/xmlrpc.py
@@ -227,7 +227,6 @@ class BitBakeXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
227 self.end_headers() 227 self.end_headers()
228 self.wfile.write(response) 228 self.wfile.write(response)
229 229
230
231class BitBakeUIEventServer(threading.Thread): 230class BitBakeUIEventServer(threading.Thread):
232 class EventAdapter(): 231 class EventAdapter():
233 """ 232 """
@@ -273,9 +272,10 @@ class BitBakeUIEventServer(threading.Thread):
273 if evt: 272 if evt:
274 self.connection.event.sendpickle(pickle.dumps(evt)) 273 self.connection.event.sendpickle(pickle.dumps(evt))
275 274
276class BitBakeXMLRPCEventServerController(SimpleXMLRPCServer): 275class BitBakeXMLRPCEventServerController(SimpleXMLRPCServer, threading.Thread):
277 def __init__(self, interface): 276 def __init__(self, interface):
278 SimpleXMLRPCServer.__init__(self, interface, logRequests=False, allow_none=True) 277 SimpleXMLRPCServer.__init__(self, interface, logRequests=False, allow_none=True)
278 threading.Thread.__init__(self)
279 self.register_function(self.registerEventHandler, "registerEventHandler") 279 self.register_function(self.registerEventHandler, "registerEventHandler")
280 self.register_function(self.unregisterEventHandler, "unregisterEventHandler") 280 self.register_function(self.unregisterEventHandler, "unregisterEventHandler")
281 self.register_function(self.terminateServer, "terminateServer") 281 self.register_function(self.terminateServer, "terminateServer")
@@ -283,6 +283,7 @@ class BitBakeXMLRPCEventServerController(SimpleXMLRPCServer):
283 self.quit = False 283 self.quit = False
284 self.clients = {} 284 self.clients = {}
285 self.client_ui_ids = {} 285 self.client_ui_ids = {}
286 self.timeout = 1 # timeout for .handle_request()
286 287
287 def registerEventHandler(self, host, port): 288 def registerEventHandler(self, host, port):
288 """ 289 """
@@ -317,13 +318,14 @@ class BitBakeXMLRPCEventServerController(SimpleXMLRPCServer):
317 def runCommand(self, cmd): 318 def runCommand(self, cmd):
318 return None 319 return None
319 320
320 def serve_forever(self, main_server): 321 def run(self):
321 self.main_server = main_server 322 self.serve_forever()
323
324 def serve_forever(self):
322 while not self.quit: 325 while not self.quit:
323 self.handle_request() 326 self.handle_request()
324 self.server_close() 327 self.server_close()
325 328
326
327class XMLRPCProxyServer(BaseImplServer): 329class XMLRPCProxyServer(BaseImplServer):
328 """ not a real working server, but a stub for a proxy server connection 330 """ not a real working server, but a stub for a proxy server connection
329 331
@@ -368,15 +370,11 @@ class XMLRPCServer(SimpleXMLRPCServer, BaseImplServer):
368 370
369 def serve_forever(self): 371 def serve_forever(self):
370 # Create and run the event server controller in a separate thread 372 # Create and run the event server controller in a separate thread
371 evt_server_ctrl = BitBakeXMLRPCEventServerController((self.host, self.port + 2)) 373 self.event_controller_thread = BitBakeXMLRPCEventServerController((self.host, self.port + 2))
372 self.event_controller_thread = threading.Thread(target = evt_server_ctrl.serve_forever, args = (self,))
373 self.event_controller_thread.start() 374 self.event_controller_thread.start()
374 # Start the actual XMLRPC server 375 # Start the actual XMLRPC server
375 bb.cooker.server_main(self.cooker, self._serve_forever) 376 bb.cooker.server_main(self.cooker, self._serve_forever)
376 377
377 def removeClient(self):
378 self.commands.removeClient()
379
380 def _serve_forever(self): 378 def _serve_forever(self):
381 """ 379 """
382 Serve Requests. Overloaded to honor a quit command 380 Serve Requests. Overloaded to honor a quit command
@@ -453,7 +451,7 @@ class BitBakeXMLRPCServerConnection(BitBakeBaseServerConnection):
453 except: 451 except:
454 pass 452 pass
455 try: 453 try:
456 self.connection.terminateServer() 454 self.connection.removeClient()
457 except: 455 except:
458 pass 456 pass
459 457