server/process: Remove pointless process forking
PATCH 1/3 server/process: Remove pointless process forking
We already call bb.daemonize.createDaemon() in BitBakeServer so the extra multiprocessing.Process() appears to be totally unneeded and just an extra layer of forking which confuses things. Remove it.
Signed-off-by Richard Purdie <[email protected]>
--- lib/bb/server/process.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
lib/bb/server/process.py +2 -3
@@ -34,12 +34,11 @@ logger = logging.getLogger('BitBake') class ProcessTimeout(SystemExit): pass -class ProcessServer(multiprocessing.Process): +class ProcessServer(): profile_filename = "profile.log" profile_processed_filename = "profile.log.processed" def __init__(self, lock, sock, sockname): - multiprocessing.Process.__init__(self) self.command_channel = False self.command_channel_reply = False self.quit = False
@@ -483,7 +482,7 @@ class BitBakeServer(object): print("Started bitbake server pid %d" % os.getpid()) sys.stdout.flush() - server.start() + server.run() def connectProcessServer(sockname, featureset): # Connect to socket
Signature · 1 line
2.25.1
PATCH 2/3 server/process: Simplfy idle callback handler function
Having the idle callbacks abstracted via the configuration object makes no sense. Its like this for historical reasons from the multiple server backends but we don't need this now so simplfy.
Signed-off-by Richard Purdie <[email protected]>
--- lib/bb/command.py | 2 +- lib/bb/cooker.py | 10 ++++++---- lib/bb/cookerdata.py | 8 +------- lib/bb/server/process.py | 3 +-- 4 files changed, 9 insertions(+), 14 deletions(-)
lib/bb/command.py +1 -1
@@ -84,7 +84,7 @@ class Command: if command not in CommandsAsync.__dict__: return None, "No such command" self.currentAsyncCommand = (command, commandline) - self.cooker.configuration.server_register_idlecallback(self.cooker.runCommands, self.cooker) + self.cooker.idleCallBackRegister(self.cooker.runCommands, self.cooker) return True, None def runAsyncCommand(self):
lib/bb/cooker.py +6 -4
@@ -148,7 +148,7 @@ class BBCooker: Manages one bitbake build run """ - def __init__(self, configuration, featureSet=None): + def __init__(self, configuration, featureSet=None, idleCallBackRegister=None): self.recipecaches = None self.skiplist = {} self.featureset = CookerFeatures()
@@ -158,6 +158,8 @@ class BBCooker: self.configuration = configuration + self.idleCallBackRegister = idleCallBackRegister + bb.debug(1, "BBCooker starting %s" % time.time()) sys.stdout.flush()
@@ -210,7 +212,7 @@ class BBCooker: cooker.process_inotify_updates() return 1.0 - self.configuration.server_register_idlecallback(_process_inotify_updates, self) + self.idleCallBackRegister(_process_inotify_updates, self) # TOSTOP must not be set or our children will hang when they output try:
@@ -1423,7 +1425,7 @@ class BBCooker: return True return retval - self.configuration.server_register_idlecallback(buildFileIdle, rq) + self.idleCallBackRegister(buildFileIdle, rq) def buildTargets(self, targets, task): """
@@ -1494,7 +1496,7 @@ class BBCooker: if 'universe' in targets: rq.rqdata.warn_multi_bb = True - self.configuration.server_register_idlecallback(buildTargetsIdle, rq) + self.idleCallBackRegister(buildTargetsIdle, rq) def getAllKeysWithFlags(self, flaglist):
lib/bb/cookerdata.py +1 -7
@@ -143,16 +143,10 @@ class CookerConfiguration(object): setattr(self, key, parameters.options.__dict__[key]) self.env = parameters.environment.copy() - def setServerRegIdleCallback(self, srcb): - self.server_register_idlecallback = srcb - def __getstate__(self): state = {} for key in self.__dict__.keys(): - if key == "server_register_idlecallback": - state[key] = None - else: - state[key] = getattr(self, key) + state[key] = getattr(self, key) return state def __setstate__(self,state):
lib/bb/server/process.py +1 -2
@@ -467,11 +467,10 @@ class BitBakeServer(object): sys.stdout.flush() server = ProcessServer(self.bitbake_lock, self.sock, self.sockname) - self.configuration.setServerRegIdleCallback(server.register_idle_function) os.close(self.readypipe) writer = ConnectionWriter(self.readypipein) try: - self.cooker = bb.cooker.BBCooker(self.configuration, self.featureset) + self.cooker = bb.cooker.BBCooker(self.configuration, self.featureset, server.register_idle_function) except bb.BBHandledException: return None writer.send("r")
Signature · 1 line
2.25.1
PATCH 3/3 server/process: Pass timeout/xmlrpc parameters directly to the server
In reply to Richard PurdieFurther cleanup, just pass these settings directly.
Signed-off-by Richard Purdie <[email protected]>
--- lib/bb/server/process.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
lib/bb/server/process.py +5 -4
@@ -38,7 +38,7 @@ class ProcessServer(): profile_filename = "profile.log" profile_processed_filename = "profile.log.processed" - def __init__(self, lock, sock, sockname): + def __init__(self, lock, sock, sockname, server_timeout, xmlrpcinterface): self.command_channel = False self.command_channel_reply = False self.quit = False
@@ -57,6 +57,9 @@ class ProcessServer(): self.sock = sock self.sockname = sockname + self.server_timeout = server_timeout + self.xmlrpcinterface = xmlrpcinterface + def register_idle_function(self, function, data): """Register a function to be called while the server is idle""" assert hasattr(function, '__call__')
@@ -466,7 +469,7 @@ class BitBakeServer(object): print(self.start_log_format % (os.getpid(), datetime.datetime.now().strftime(self.start_log_datetime_format))) sys.stdout.flush() - server = ProcessServer(self.bitbake_lock, self.sock, self.sockname) + server = ProcessServer(self.bitbake_lock, self.sock, self.sockname, self.configuration.server_timeout, self.configuration.xmlrpcinterface) os.close(self.readypipe) writer = ConnectionWriter(self.readypipein) try:
@@ -476,8 +479,6 @@ class BitBakeServer(object): writer.send("r") writer.close() server.cooker = self.cooker - server.server_timeout = self.configuration.server_timeout - server.xmlrpcinterface = self.configuration.xmlrpcinterface print("Started bitbake server pid %d" % os.getpid()) sys.stdout.flush()
Signature · 1 line
2.25.1