aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-10-05 14:39:28 +0000
committerGerrit Code Review <review@openstack.org>2016-10-05 14:39:28 +0000
commit9413e4d27c2a0e12e8d348ab6f9ec67043f5ec1e (patch)
treeba6d90ae03eb35dc9f22f1908c1e2828d59daa26
parent1932552a05344eff215c9e5e41e5cccf1a063f0d (diff)
parente8e1ad70893496f8956559775391500149a1205d (diff)
downloadkolla-9413e4d27c2a0e12e8d348ab6f9ec67043f5ec1e.tar.gz
kolla-9413e4d27c2a0e12e8d348ab6f9ec67043f5ec1e.zip
Merge "Handle the KeyboardInterrunpt properly for build.py script"
-rw-r--r--kolla/image/build.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/kolla/image/build.py b/kolla/image/build.py
index eee5b036b..d0d36a457 100644
--- a/kolla/image/build.py
+++ b/kolla/image/build.py
@@ -117,9 +117,21 @@ STATUS_ERRORS = (STATUS_CONNECTION_ERROR, STATUS_PUSH_ERROR,
def join_many(threads):
try:
yield
- finally:
for t in threads:
t.join()
+ except KeyboardInterrupt:
+ try:
+ LOG.info('Waiting for daemon threads exit. Push Ctrl + c again to'
+ ' force exit')
+ for t in threads:
+ if t.is_alive():
+ LOG.debug('Waiting thread %s to exit', t.name)
+ # NOTE(Jeffrey4l): Python Bug: When join without timeout,
+ # KeyboardInterrupt is never sent.
+ t.join(0xffff)
+ LOG.debug('Thread %s exits', t.name)
+ except KeyboardInterrupt:
+ LOG.warning('Force exits')
class DockerTask(task.Task):
@@ -974,6 +986,7 @@ def run_build():
for x in six.moves.range(conf.push_threads):
worker = WorkerThread(conf, push_queue)
+ worker.setDaemon(True)
worker.start()
workers.append(worker)