summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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