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
This commit is contained in:
parent
0226cca1a2
commit
e8e1ad7089
@ -117,9 +117,21 @@ STATUS_ERRORS = (STATUS_CONNECTION_ERROR, STATUS_PUSH_ERROR,
|
|||||||
def join_many(threads):
|
def join_many(threads):
|
||||||
try:
|
try:
|
||||||
yield
|
yield
|
||||||
finally:
|
|
||||||
for t in threads:
|
for t in threads:
|
||||||
t.join()
|
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):
|
class DockerTask(task.Task):
|
||||||
@ -974,6 +986,7 @@ def run_build():
|
|||||||
|
|
||||||
for x in six.moves.range(conf.push_threads):
|
for x in six.moves.range(conf.push_threads):
|
||||||
worker = WorkerThread(conf, push_queue)
|
worker = WorkerThread(conf, push_queue)
|
||||||
|
worker.setDaemon(True)
|
||||||
worker.start()
|
worker.start()
|
||||||
workers.append(worker)
|
workers.append(worker)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user