summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-09 10:04:41 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-10 11:09:59 -0700
commit6f3a537dda7ea84379fc11c1ec42cfdfeaf68bd4 (patch)
tree506953ce4cc454423808c375856c4e96bb1cc3de /bitbake
parent8fbe21845c67a81e79039268717941312fbc7d30 (diff)
downloadpoky-6f3a537dda7ea84379fc11c1ec42cfdfeaf68bd4.tar.gz
bitbake: server/process: Deal more gracefully with SIGTERM
Currently a SIGTERM to the UI process causes the UI simply to lock up. By setting an exit flag, the waitEvent can raise a SIGINT, allowing the UI to break out the event loop and exit. Currently this is results in a traceback but that is more desirable than a hanging process. (Bitbake rev: 0d12041eceeae6bba2034b04913bb13abd67bd15) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/server/process.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index 6db6a2326d..f4cb32c8aa 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -157,6 +157,10 @@ class BitBakeProcessServerConnection(BitBakeBaseServerConnection):
157 self.connection = ServerCommunicator(self.ui_channel, self.procserver.event_handle) 157 self.connection = ServerCommunicator(self.ui_channel, self.procserver.event_handle)
158 self.events = self.event_queue 158 self.events = self.event_queue
159 159
160 def sigterm_terminate(self):
161 bb.error("UI received SIGTERM")
162 self.terminate()
163
160 def terminate(self): 164 def terminate(self):
161 def flushevents(): 165 def flushevents():
162 while True: 166 while True:
@@ -176,10 +180,20 @@ class BitBakeProcessServerConnection(BitBakeBaseServerConnection):
176 180
177 self.ui_channel.close() 181 self.ui_channel.close()
178 self.event_queue.close() 182 self.event_queue.close()
183 self.event_queue.setexit()
179 184
180# Wrap Queue to provide API which isn't server implementation specific 185# Wrap Queue to provide API which isn't server implementation specific
181class ProcessEventQueue(multiprocessing.queues.Queue): 186class ProcessEventQueue(multiprocessing.queues.Queue):
187 def __init__(self, maxsize):
188 multiprocessing.queues.Queue.__init__(self, maxsize)
189 self.exit = False
190
191 def setexit(self):
192 self.exit = True
193
182 def waitEvent(self, timeout): 194 def waitEvent(self, timeout):
195 if self.exit:
196 raise KeyboardInterrupt()
183 try: 197 try:
184 return self.get(True, timeout) 198 return self.get(True, timeout)
185 except Empty: 199 except Empty:
@@ -214,5 +228,5 @@ class BitBakeServer(BitBakeBaseServer):
214 if error: 228 if error:
215 logger.error("Unable to set the cooker to the correct featureset: %s" % error) 229 logger.error("Unable to set the cooker to the correct featureset: %s" % error)
216 raise BaseException(error) 230 raise BaseException(error)
217 signal.signal(signal.SIGTERM, lambda i, s: self.connection.terminate()) 231 signal.signal(signal.SIGTERM, lambda i, s: self.connection.sigterm_terminate())
218 return self.connection 232 return self.connection