mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-07-28 17:25:05 +00:00
validate: launcher: Force kill subprocess when done with them
Making sure that we do not end up having spurious subprocess around
This commit is contained in:
parent
d25fb034fa
commit
a2abf628dc
|
@ -216,6 +216,25 @@ class Test(Loggable):
|
||||||
def get_subproc_env(self):
|
def get_subproc_env(self):
|
||||||
return os.environ
|
return os.environ
|
||||||
|
|
||||||
|
def _kill_subprocess(self):
|
||||||
|
if self.process is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
stime = time.time()
|
||||||
|
res = self.process.poll()
|
||||||
|
while res is None:
|
||||||
|
try:
|
||||||
|
self.debug("Subprocess is still alive, sending KILL signal")
|
||||||
|
self.process.send_signal(signal.SIGKILL)
|
||||||
|
time.sleep(1)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
if time.time() - stime > DEFAULT_TIMEOUT:
|
||||||
|
raise RuntimeError("Could not kill subprocess after %s second"
|
||||||
|
" Something is really wrong, => EXITING"
|
||||||
|
% DEFAULT_TIMEOUT)
|
||||||
|
res = self.process.poll()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.command = "%s " % (self.application)
|
self.command = "%s " % (self.application)
|
||||||
self._starting_time = time.time()
|
self._starting_time = time.time()
|
||||||
|
@ -241,14 +260,10 @@ class Test(Loggable):
|
||||||
env=proc_env)
|
env=proc_env)
|
||||||
self.wait_process()
|
self.wait_process()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
self.process.send_signal(signal.SIGINT)
|
self._kill_subprocess()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
try:
|
self._kill_subprocess()
|
||||||
self.process.send_signal(signal.SIGINT)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
self.time_taken = time.time() - self._starting_time
|
self.time_taken = time.time() - self._starting_time
|
||||||
|
|
||||||
if not self.reporter.uses_standard_output():
|
if not self.reporter.uses_standard_output():
|
||||||
|
|
Loading…
Reference in a new issue