diff options
-rw-r--r-- | bitbake/lib/bb/server/xmlrpc.py | 20 |
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 | |||
231 | class BitBakeUIEventServer(threading.Thread): | 230 | class 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 | ||
276 | class BitBakeXMLRPCEventServerController(SimpleXMLRPCServer): | 275 | class 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 | |||
327 | class XMLRPCProxyServer(BaseImplServer): | 329 | class 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 | ||