diff options
| author | Jeffrey Zhang <zhang.lei.fly@gmail.com> | 2016-10-02 19:12:03 +0800 |
|---|---|---|
| committer | Jeffrey Zhang <jeffrey.zhang@99cloud.net> | 2016-10-03 07:53:45 +0000 |
| commit | e8e1ad70893496f8956559775391500149a1205d (patch) | |
| tree | d4a72ca4d64edd9ddd95fc3ce20bca41f0bda0e4 /kolla | |
| parent | 0226cca1a25c59ace8433650c81f83d0b78d9a33 (diff) | |
| download | kolla-e8e1ad70893496f8956559775391500149a1205d.tar.gz kolla-e8e1ad70893496f8956559775391500149a1205d.zip | |
Handle the KeyboardInterrunpt properly for build.py script
* set the push queue worker daemon
* force exit when using twice Ctrl + c in build.py script.
Change-Id: Ib3278ee9909f94a5129854c3c6fc9720a91a19f3
Closes-Bug: #1629654
Diffstat (limited to 'kolla')
| -rw-r--r-- | kolla/image/build.py | 15 |
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) |
