summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/server/process.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2017-07-18 22:15:17 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-07-21 08:41:11 +0100
commit577b75086eaf4ae2201933f7b9ac32f6239867c6 (patch)
tree66486353161365955936a20338642c8f50dc15e8 /bitbake/lib/bb/server/process.py
parentdd71707d5a5a420a4406ce88164ac2a32cc04956 (diff)
downloadpoky-577b75086eaf4ae2201933f7b9ac32f6239867c6.tar.gz
bitbake: server: Remove base classes and inline code
In preparation for rewriting this code, expand the relatively useless base classes into the code itself. (Bitbake rev: a1c6151420d86bac658c08ae714647062edd6ef2) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/server/process.py')
-rw-r--r--bitbake/lib/bb/server/process.py34
1 files changed, 28 insertions, 6 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index cfcd76495c..48da7fe46c 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -33,8 +33,6 @@ import select
33from queue import Empty 33from queue import Empty
34from multiprocessing import Event, Process, util, Queue, Pipe, queues, Manager 34from multiprocessing import Event, Process, util, Queue, Pipe, queues, Manager
35 35
36from . import BitBakeBaseServer, BitBakeBaseServerConnection, BaseImplServer
37
38logger = logging.getLogger('BitBake') 36logger = logging.getLogger('BitBake')
39 37
40class ServerCommunicator(): 38class ServerCommunicator():
@@ -85,12 +83,12 @@ class EventAdapter():
85 print("EventAdapter puked: %s" % str(err)) 83 print("EventAdapter puked: %s" % str(err))
86 84
87 85
88class ProcessServer(Process, BaseImplServer): 86class ProcessServer(Process):
89 profile_filename = "profile.log" 87 profile_filename = "profile.log"
90 profile_processed_filename = "profile.log.processed" 88 profile_processed_filename = "profile.log.processed"
91 89
92 def __init__(self, command_channel, event_queue, featurelist): 90 def __init__(self, command_channel, event_queue, featurelist):
93 BaseImplServer.__init__(self) 91 self._idlefuns = {}
94 Process.__init__(self) 92 Process.__init__(self)
95 self.command_channel = command_channel 93 self.command_channel = command_channel
96 self.event_queue = event_queue 94 self.event_queue = event_queue
@@ -208,7 +206,15 @@ class ProcessServer(Process, BaseImplServer):
208 self.quitin.send("quit") 206 self.quitin.send("quit")
209 self.quitin.close() 207 self.quitin.close()
210 208
211class BitBakeProcessServerConnection(BitBakeBaseServerConnection): 209 def addcooker(self, cooker):
210 self.cooker = cooker
211
212 def register_idle_function(self, function, data):
213 """Register a function to be called while the server is idle"""
214 assert hasattr(function, '__call__')
215 self._idlefuns[function] = data
216
217class BitBakeProcessServerConnection(object):
212 def __init__(self, serverImpl, ui_channel, event_queue): 218 def __init__(self, serverImpl, ui_channel, event_queue):
213 self.procserver = serverImpl 219 self.procserver = serverImpl
214 self.ui_channel = ui_channel 220 self.ui_channel = ui_channel
@@ -247,6 +253,9 @@ class BitBakeProcessServerConnection(BitBakeBaseServerConnection):
247 # fd leakage because isn't called on Queue.close() 253 # fd leakage because isn't called on Queue.close()
248 self.event_queue._writer.close() 254 self.event_queue._writer.close()
249 255
256 def setupEventQueue(self):
257 pass
258
250# Wrap Queue to provide API which isn't server implementation specific 259# Wrap Queue to provide API which isn't server implementation specific
251class ProcessEventQueue(multiprocessing.queues.Queue): 260class ProcessEventQueue(multiprocessing.queues.Queue):
252 def __init__(self, maxsize): 261 def __init__(self, maxsize):
@@ -279,7 +288,7 @@ class ProcessEventQueue(multiprocessing.queues.Queue):
279 sys.exit(1) 288 sys.exit(1)
280 return None 289 return None
281 290
282class BitBakeServer(BitBakeBaseServer): 291class BitBakeServer(object):
283 def initServer(self, single_use=True): 292 def initServer(self, single_use=True):
284 # establish communication channels. We use bidirectional pipes for 293 # establish communication channels. We use bidirectional pipes for
285 # ui <--> server command/response pairs 294 # ui <--> server command/response pairs
@@ -304,3 +313,16 @@ class BitBakeServer(BitBakeBaseServer):
304 raise BaseException(error) 313 raise BaseException(error)
305 signal.signal(signal.SIGTERM, lambda i, s: self.connection.sigterm_terminate()) 314 signal.signal(signal.SIGTERM, lambda i, s: self.connection.sigterm_terminate())
306 return self.connection 315 return self.connection
316
317 def addcooker(self, cooker):
318 self.cooker = cooker
319 self.serverImpl.addcooker(cooker)
320
321 def getServerIdleCB(self):
322 return self.serverImpl.register_idle_function
323
324 def saveConnectionDetails(self):
325 return
326
327 def endSession(self):
328 self.connection.terminate()