summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/server
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-11-13 21:23:54 +0800
committerRichard Purdie <rpurdie@linux.intel.com>2010-11-13 21:23:54 +0800
commit05ba6fc7cb5a389737a238f312f4148e6b837d71 (patch)
tree7b0d8688095f94fd2010c63f0b0aadff301eccbf /bitbake/lib/bb/server
parent89929e1f283c8508c505c9731ad933880abf22a1 (diff)
downloadpoky-05ba6fc7cb5a389737a238f312f4148e6b837d71.tar.gz
bitbake: Rewrite profiling code so its functional for both none and xmlrpc backends
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/server')
-rw-r--r--bitbake/lib/bb/server/none.py16
-rw-r--r--bitbake/lib/bb/server/xmlrpc.py19
2 files changed, 29 insertions, 6 deletions
diff --git a/bitbake/lib/bb/server/none.py b/bitbake/lib/bb/server/none.py
index 14915d9737..38f713c519 100644
--- a/bitbake/lib/bb/server/none.py
+++ b/bitbake/lib/bb/server/none.py
@@ -109,9 +109,11 @@ class BitBakeServer():
109 # remove this when you're done with debugging 109 # remove this when you're done with debugging
110 # allow_reuse_address = True 110 # allow_reuse_address = True
111 111
112 def __init__(self, cooker): 112 def __init__(self, cooker, pre_serve, post_serve):
113 self._idlefuns = {} 113 self._idlefuns = {}
114 self.commands = BitBakeServerCommands(self, cooker) 114 self.commands = BitBakeServerCommands(self, cooker)
115 self.pre_serve = pre_serve
116 self.post_serve = post_serve
115 117
116 def register_idle_function(self, function, data): 118 def register_idle_function(self, function, data):
117 """Register a function to be called while the server is idle""" 119 """Register a function to be called while the server is idle"""
@@ -160,9 +162,17 @@ class BitbakeServerInfo():
160 self.commands = server.commands 162 self.commands = server.commands
161 163
162class BitBakeServerFork(): 164class BitBakeServerFork():
163 def __init__(self, serverinfo, command, logfile): 165 def __init__(self, cooker, server, serverinfo, logfile):
164 serverinfo.forkCommand = command
165 serverinfo.logfile = logfile 166 serverinfo.logfile = logfile
167 serverinfo.cooker = cooker
168 serverinfo.server = server
169
170class BitbakeUILauch():
171 def launch(self, serverinfo, uifunc, *args):
172 serverinfo.server.pre_serve()
173 ret = bb.cooker.server_main(serverinfo.cooker, uifunc, *args)
174 serverinfo.server.post_serve()
175 return ret
166 176
167class BitBakeServerConnection(): 177class BitBakeServerConnection():
168 def __init__(self, serverinfo): 178 def __init__(self, serverinfo):
diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py
index cb2949fb9f..30b83d2b13 100644
--- a/bitbake/lib/bb/server/xmlrpc.py
+++ b/bitbake/lib/bb/server/xmlrpc.py
@@ -87,7 +87,7 @@ class BitBakeServer(SimpleXMLRPCServer):
87 # remove this when you're done with debugging 87 # remove this when you're done with debugging
88 # allow_reuse_address = True 88 # allow_reuse_address = True
89 89
90 def __init__(self, cooker, interface = ("localhost", 0)): 90 def __init__(self, cooker, pre_serve, post_serve, interface = ("localhost", 0)):
91 """ 91 """
92 Constructor 92 Constructor
93 """ 93 """
@@ -99,6 +99,9 @@ class BitBakeServer(SimpleXMLRPCServer):
99 #self.register_introspection_functions() 99 #self.register_introspection_functions()
100 commands = BitBakeServerCommands(self, cooker) 100 commands = BitBakeServerCommands(self, cooker)
101 self.autoregister_all_functions(commands, "") 101 self.autoregister_all_functions(commands, "")
102 self.cooker = cooker
103 self.pre_serve = pre_serve
104 self.post_serve = post_serve
102 105
103 def autoregister_all_functions(self, context, prefix): 106 def autoregister_all_functions(self, context, prefix):
104 """ 107 """
@@ -116,9 +119,14 @@ class BitBakeServer(SimpleXMLRPCServer):
116 self._idlefuns[function] = data 119 self._idlefuns[function] = data
117 120
118 def serve_forever(self): 121 def serve_forever(self):
122 bb.cooker.server_main(self.cooker, self._serve_forever)
123
124 def _serve_forever(self):
119 """ 125 """
120 Serve Requests. Overloaded to honor a quit command 126 Serve Requests. Overloaded to honor a quit command
121 """ 127 """
128 self.pre_serve()
129
122 self.quit = False 130 self.quit = False
123 self.timeout = 0 # Run Idle calls for our first callback 131 self.timeout = 0 # Run Idle calls for our first callback
124 while not self.quit: 132 while not self.quit:
@@ -155,6 +163,7 @@ class BitBakeServer(SimpleXMLRPCServer):
155 except: 163 except:
156 pass 164 pass
157 165
166 self.post_serve()
158 self.server_close() 167 self.server_close()
159 return 168 return
160 169
@@ -164,8 +173,12 @@ class BitbakeServerInfo():
164 self.port = server.port 173 self.port = server.port
165 174
166class BitBakeServerFork(): 175class BitBakeServerFork():
167 def __init__(self, serverinfo, command, logfile): 176 def __init__(self, cooker, server, serverinfo, logfile):
168 daemonize.createDaemon(command, logfile) 177 daemonize.createDaemon(server.serve_forever, logfile)
178
179class BitbakeUILauch():
180 def launch(self, serverinfo, uifunc, *args):
181 return uifunc(*args)
169 182
170class BitBakeServerConnection(): 183class BitBakeServerConnection():
171 def __init__(self, serverinfo): 184 def __init__(self, serverinfo):