From 2a6da3e4112a54734a7338df55bc9433319b3ead Mon Sep 17 00:00:00 2001 From: David McKay Date: Sat, 18 Mar 2017 15:27:12 -0500 Subject: [PATCH 1/2] Adopting 'background' first on Cntrl-C and allowing second and third taps to be stop and kill Signed-off-by: David McKay --- compose/cli/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/compose/cli/main.py b/compose/cli/main.py index 63a0036b4e1..a7c6449df34 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -10,6 +10,7 @@ import re import subprocess import sys +import time from distutils.spawn import find_executable from inspect import getdoc from operator import attrgetter @@ -52,7 +53,6 @@ from .utils import human_readable_file_size from .utils import yesno - if not IS_WINDOWS_PLATFORM: from dockerpty.pty import PseudoTerminal, RunOperation, ExecOperation @@ -1200,7 +1200,11 @@ def up_shutdown_context(project, service_names, timeout, detached): signals.set_signal_handler_to_shutdown() try: try: - yield + try: + yield + except signals.ShutdownException: + print("Backgrounding in 2 seconds ... (press Ctrl+c again to stop)") + time.sleep(2) except signals.ShutdownException: print("Gracefully stopping... (press Ctrl+C again to force)") project.stop(service_names=service_names, timeout=timeout) @@ -1208,7 +1212,6 @@ def up_shutdown_context(project, service_names, timeout, detached): project.kill(service_names=service_names) sys.exit(2) - def list_containers(containers): return ", ".join(c.name for c in containers) From b3fb804b6f2dd2970d968132f33dec0b89cc12d7 Mon Sep 17 00:00:00 2001 From: David McKay Date: Sun, 19 Mar 2017 05:53:11 -0500 Subject: [PATCH 2/2] Adding additional blank line to satisfy flake8 Signed-off-by: David McKay --- compose/cli/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/compose/cli/main.py b/compose/cli/main.py index a7c6449df34..55a7d337cbc 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -1212,6 +1212,7 @@ def up_shutdown_context(project, service_names, timeout, detached): project.kill(service_names=service_names) sys.exit(2) + def list_containers(containers): return ", ".join(c.name for c in containers)