mirror of
https://git.yoctoproject.org/poky
synced 2026-02-15 13:13:02 +01:00
Implementing feature set selection that allows a client to enable specific features in the server at connection time. Only enabling of features is supported, as there is no way to safely remove data loaded into the cooker. Once enabled, a feature will remain enabled for the life of the cooker. Client-server connection now supports specifying the feature set required by the client. This is implemented in the Process server using a managed proxy list, so the server cooker will now load dynamically needed features based on what client connects to it. In the XMLRPC server the feature set is requested by using a parameter for registerUIHandler function. This allows observer-only clients to also specify features for the server. The server code configuration now is completly separated from the client code. All hardcoding of client knowledge is removed from the server. The extra_caches is removed as the client can now specify the caches it needs using the feature. The UI modules now need to specify the desired featureSet. HOB is modified to conform to the featureSet specification. The only feature available is CookerFeatures.HOB_EXTRA_CACHES which forces loading the bb.cache_extra:HobRecipeInfo class. (Bitbake rev: 98e594837aab89ea042cfa9f3740d20a661b14e2) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
134 lines
4.1 KiB
Python
134 lines
4.1 KiB
Python
# ex:ts=4:sw=4:sts=4:et
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
#
|
|
# Copyright (C) 2006 - 2007 Michael 'Mickey' Lauer
|
|
# Copyright (C) 2006 - 2007 Richard Purdie
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License version 2 as
|
|
# published by the Free Software Foundation.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
|
"""
|
|
Use this class to fork off a thread to recieve event callbacks from the bitbake
|
|
server and queue them for the UI to process. This process must be used to avoid
|
|
client/server deadlocks.
|
|
"""
|
|
|
|
import socket, threading, pickle
|
|
from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
|
|
|
|
class BBUIEventQueue:
|
|
def __init__(self, BBServer, clientinfo=("localhost, 0"), featureset=[]):
|
|
|
|
self.eventQueue = []
|
|
self.eventQueueLock = threading.Lock()
|
|
self.eventQueueNotify = threading.Event()
|
|
|
|
self.BBServer = BBServer
|
|
self.clientinfo = clientinfo
|
|
|
|
server = UIXMLRPCServer(self.clientinfo)
|
|
self.host, self.port = server.socket.getsockname()
|
|
|
|
server.register_function( self.system_quit, "event.quit" )
|
|
server.register_function( self.send_event, "event.sendpickle" )
|
|
server.socket.settimeout(1)
|
|
|
|
self.EventHandle = self.BBServer.registerEventHandler(self.host, self.port, featureset)
|
|
|
|
if (self.EventHandle == None):
|
|
bb.fatal("Could not register UI event handler")
|
|
|
|
self.server = server
|
|
|
|
self.t = threading.Thread()
|
|
self.t.setDaemon(True)
|
|
self.t.run = self.startCallbackHandler
|
|
self.t.start()
|
|
|
|
def getEvent(self):
|
|
|
|
self.eventQueueLock.acquire()
|
|
|
|
if len(self.eventQueue) == 0:
|
|
self.eventQueueLock.release()
|
|
return None
|
|
|
|
item = self.eventQueue.pop(0)
|
|
|
|
if len(self.eventQueue) == 0:
|
|
self.eventQueueNotify.clear()
|
|
|
|
self.eventQueueLock.release()
|
|
return item
|
|
|
|
def waitEvent(self, delay):
|
|
self.eventQueueNotify.wait(delay)
|
|
return self.getEvent()
|
|
|
|
def queue_event(self, event):
|
|
self.eventQueueLock.acquire()
|
|
self.eventQueue.append(event)
|
|
self.eventQueueNotify.set()
|
|
self.eventQueueLock.release()
|
|
|
|
def send_event(self, event):
|
|
self.queue_event(pickle.loads(event))
|
|
|
|
def startCallbackHandler(self):
|
|
|
|
self.server.timeout = 1
|
|
while not self.server.quit:
|
|
self.server.handle_request()
|
|
self.server.server_close()
|
|
|
|
def system_quit( self ):
|
|
"""
|
|
Shut down the callback thread
|
|
"""
|
|
try:
|
|
self.BBServer.unregisterEventHandler(self.EventHandle)
|
|
except:
|
|
pass
|
|
self.server.quit = True
|
|
|
|
class UIXMLRPCServer (SimpleXMLRPCServer):
|
|
|
|
def __init__( self, interface ):
|
|
self.quit = False
|
|
SimpleXMLRPCServer.__init__( self,
|
|
interface,
|
|
requestHandler=SimpleXMLRPCRequestHandler,
|
|
logRequests=False, allow_none=True)
|
|
|
|
def get_request(self):
|
|
while not self.quit:
|
|
try:
|
|
sock, addr = self.socket.accept()
|
|
sock.settimeout(1)
|
|
return (sock, addr)
|
|
except socket.timeout:
|
|
pass
|
|
return (None, None)
|
|
|
|
def close_request(self, request):
|
|
if request is None:
|
|
return
|
|
SimpleXMLRPCServer.close_request(self, request)
|
|
|
|
def process_request(self, request, client_address):
|
|
if request is None:
|
|
return
|
|
SimpleXMLRPCServer.process_request(self, request, client_address)
|
|
|