summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/server
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2014-08-21 10:27:10 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-08-23 09:31:42 +0100
commitd33cc89e538b6cf4ffb4cdef8c51ef8960cb47f4 (patch)
treea4a47a056f5bb7cdcac5a1918d40547f69c5650e /bitbake/lib/bb/server
parent8683c244c1c815dfab15e6cf67f17bb5d82505ef (diff)
downloadpoky-d33cc89e538b6cf4ffb4cdef8c51ef8960cb47f4.tar.gz
bitbake: process: Further improve robustness against server shutdown
Currently, if an exception occurs in an event handler, the server shuts down but the UI simply hangs. This happens in two places, firstly waiting for events and secondly, sending events to a server which no longer exists. The latter does time out, the former does not. These patches improve both code sections to check if the main server process is alive and if not, trigger things to shut down gracefully. This avoids the timeout in the command sending case too. This resolves various cases where the UI would simply hang indefintely. (Bitbake rev: ac418e1112ff5f9c3157569316902f7a27fba4b4) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/server')
-rw-r--r--bitbake/lib/bb/server/process.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index 84f3a75412..4bfff45f01 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -38,14 +38,18 @@ from . import BitBakeBaseServer, BitBakeBaseServerConnection, BaseImplServer
38logger = logging.getLogger('BitBake') 38logger = logging.getLogger('BitBake')
39 39
40class ServerCommunicator(): 40class ServerCommunicator():
41 def __init__(self, connection, event_handle): 41 def __init__(self, connection, event_handle, server):
42 self.connection = connection 42 self.connection = connection
43 self.event_handle = event_handle 43 self.event_handle = event_handle
44 self.server = server
44 45
45 def runCommand(self, command): 46 def runCommand(self, command):
46 # @todo try/except 47 # @todo try/except
47 self.connection.send(command) 48 self.connection.send(command)
48 49
50 if not self.server.is_alive():
51 raise SystemExit
52
49 while True: 53 while True:
50 # don't let the user ctrl-c while we're waiting for a response 54 # don't let the user ctrl-c while we're waiting for a response
51 try: 55 try:
@@ -160,7 +164,7 @@ class BitBakeProcessServerConnection(BitBakeBaseServerConnection):
160 self.procserver = serverImpl 164 self.procserver = serverImpl
161 self.ui_channel = ui_channel 165 self.ui_channel = ui_channel
162 self.event_queue = event_queue 166 self.event_queue = event_queue
163 self.connection = ServerCommunicator(self.ui_channel, self.procserver.event_handle) 167 self.connection = ServerCommunicator(self.ui_channel, self.procserver.event_handle, self.procserver)
164 self.events = self.event_queue 168 self.events = self.event_queue
165 169
166 def sigterm_terminate(self): 170 def sigterm_terminate(self):
@@ -199,14 +203,20 @@ class ProcessEventQueue(multiprocessing.queues.Queue):
199 203
200 def waitEvent(self, timeout): 204 def waitEvent(self, timeout):
201 if self.exit: 205 if self.exit:
202 raise KeyboardInterrupt() 206 raise SystemExit
203 try: 207 try:
208 if not self.server.is_alive():
209 self.setexit()
210 return None
204 return self.get(True, timeout) 211 return self.get(True, timeout)
205 except Empty: 212 except Empty:
206 return None 213 return None
207 214
208 def getEvent(self): 215 def getEvent(self):
209 try: 216 try:
217 if not self.server.is_alive():
218 self.setexit()
219 return None
210 return self.get(False) 220 return self.get(False)
211 except Empty: 221 except Empty:
212 return None 222 return None
@@ -221,6 +231,7 @@ class BitBakeServer(BitBakeBaseServer):
221 self.ui_channel, self.server_channel = Pipe() 231 self.ui_channel, self.server_channel = Pipe()
222 self.event_queue = ProcessEventQueue(0) 232 self.event_queue = ProcessEventQueue(0)
223 self.serverImpl = ProcessServer(self.server_channel, self.event_queue, None) 233 self.serverImpl = ProcessServer(self.server_channel, self.event_queue, None)
234 self.event_queue.server = self.serverImpl
224 235
225 def detach(self): 236 def detach(self):
226 self.serverImpl.start() 237 self.serverImpl.start()