diff options
author | Bob Foerster <rfoerster@layerzero.com> | 2010-11-24 12:53:12 -0500 |
---|---|---|
committer | Chris Larson <chris_larson@mentor.com> | 2010-12-16 10:39:27 -0700 |
commit | 65b615c6df4c3891e3c600947c3f96f802407fa4 (patch) | |
tree | cbb38412957c5be0d9a5f0c7c56d9ccd272e9c6e /bin/bitbake | |
parent | 144887553097a288a76b8de78f71548d5ef9a350 (diff) | |
download | bitbake-65b615c6df4c3891e3c600947c3f96f802407fa4.tar.gz |
Run the server and UI in separate processes
This uses the python multiprocessing module, both to spawn the server process
and for communication between the processes.
Signed-off-by: Bob Foerster <robert@erafx.com>
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'bin/bitbake')
-rwxr-xr-x | bin/bitbake | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/bin/bitbake b/bin/bitbake index d88d6c713..346ce9bea 100755 --- a/bin/bitbake +++ b/bin/bitbake @@ -39,11 +39,21 @@ import bb.msg from bb import cooker from bb import ui from bb import server -from bb.server import none +from bb.server.process import ProcessServer + +from multiprocessing import Queue, Pipe __version__ = "1.11.0" logger = logging.getLogger("BitBake") +class ServerCommunicator(): + def __init__(self, connection): + self.connection = connection + + def runCommand(self, command): + # @todo try/except + self.connection.send(command) + return self.connection.recv() class BBConfiguration(object): """ @@ -167,15 +177,6 @@ Default BBFILES are the .bb files in the current directory.""") ui_main = get_ui(configuration) - loghandler = event.LogHandler() - logger.addHandler(loghandler) - - server = bb.server.none - - # Save a logfile for cooker into the current working directory. When the - # server is daemonized this logfile will be truncated. - cooker_logfile = os.path.join(os.getcwd(), "cooker.log") - bb.utils.init_logger(bb.msg, configuration.verbose, configuration.debug, configuration.debug_domains) @@ -184,23 +185,25 @@ Default BBFILES are the .bb files in the current directory.""") # of the UIs (e.g. for DISPLAY, etc.) bb.utils.clean_environment() - cooker = bb.cooker.BBCooker(configuration, server) - cooker.parseCommandLine() + # establish communication channels. We use bidirectional pipes for + # ui <--> server command/response pairs + # and a queue for server -> ui event notifications + # + ui_channel, server_channel = Pipe() + event_queue = Queue() - serverinfo = server.BitbakeServerInfo(cooker.server) - - server.BitBakeServerFork(serverinfo, cooker.serve, cooker_logfile) - del cooker - - logger.removeHandler(loghandler) - - # Setup a connection to the server (cooker) - server_connection = server.BitBakeServerConnection(serverinfo) + server = ProcessServer(server_channel, event_queue, configuration) + server.start() try: return ui_main(server_connection.connection, server_connection.events) finally: - server_connection.terminate() + server.stop() + ui_channel.close() + event_queue.close() + server.join() + + return return_value if __name__ == "__main__": try: @@ -210,3 +213,4 @@ if __name__ == "__main__": import traceback traceback.print_exc(5) sys.exit(ret) + |