Skip to content

Commit

Permalink
docker: Terminate instances at SIGTERM and SIGHUP
Browse files Browse the repository at this point in the history
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <1474429768-25027-9-git-send-email-famz@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
  • Loading branch information
Fam Zheng committed Sep 23, 2016
1 parent ec960b9 commit 97cba1a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/docker/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import argparse
import tempfile
import re
import signal
from tarfile import TarFile, TarInfo
from StringIO import StringIO
from shutil import copy, rmtree
Expand Down Expand Up @@ -101,6 +102,8 @@ def __init__(self):
self._command = _guess_docker_command()
self._instances = []
atexit.register(self._kill_instances)
signal.signal(signal.SIGTERM, self._kill_instances)
signal.signal(signal.SIGHUP, self._kill_instances)

def _do(self, cmd, quiet=True, infile=None, **kwargs):
if quiet:
Expand Down Expand Up @@ -133,7 +136,7 @@ def clean(self):
self._do_kill_instances(False, False)
return 0

def _kill_instances(self):
def _kill_instances(self, *args, **kwargs):
return self._do_kill_instances(True)

def _output(self, cmd, **kwargs):
Expand Down

0 comments on commit 97cba1a

Please sign in to comment.