Implement non-default signal handler for SIGINT
Pressing Ctrl-C will stop a build, but does not clean up the /tmp directory of dockerfiles. Implement a signal handler such that clean up does occur. Python apparently ignores signals while calling join on a queue, so that's why the small modification was needed there. Change-Id: I43faf67726c154b6640d3596aea61ffc59871999 Closes-Bug: #1579242
This commit is contained in:
parent
696f0b9a06
commit
75492cf82b
@ -12,7 +12,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
# TODO(jpeeler): Add clean up handler for SIGINT
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
@ -55,7 +54,13 @@ logging.basicConfig()
|
|||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
LOG.setLevel(logging.INFO)
|
LOG.setLevel(logging.INFO)
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
|
||||||
|
def handle_ctrlc(single, frame):
|
||||||
|
kollaobj = frame.f_locals['kolla']
|
||||||
|
kollaobj.cleanup()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
signal.signal(signal.SIGINT, handle_ctrlc)
|
||||||
|
|
||||||
|
|
||||||
class KollaDirNotFoundException(Exception):
|
class KollaDirNotFoundException(Exception):
|
||||||
@ -773,9 +778,9 @@ def main():
|
|||||||
push_thread = PushThread(conf, push_queue)
|
push_thread = PushThread(conf, push_queue)
|
||||||
push_thread.start()
|
push_thread.start()
|
||||||
|
|
||||||
# block until queue is empty
|
# sleep until queue is empty
|
||||||
queue.join()
|
while queue.unfinished_tasks or push_queue.unfinished_tasks:
|
||||||
push_queue.join()
|
time.sleep(3)
|
||||||
|
|
||||||
kolla.summary()
|
kolla.summary()
|
||||||
kolla.cleanup()
|
kolla.cleanup()
|
||||||
|
Loading…
Reference in New Issue
Block a user