summaryrefslogtreecommitdiffstats
path: root/src/osmo_gsm_tester/process.py
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-10-25 18:31:50 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2018-10-26 10:24:59 +0000
commit8aca1f37d6a8a7c772b1ae95ed8825f185253eaa (patch)
tree11ff0ff6b5c61e0b5695636c6a1f155db979495d /src/osmo_gsm_tester/process.py
parentd03acdf38ab75d90d588c4990076a3f763882583 (diff)
process: Make sure sync process is terminated if ogt is stopped
Diffstat (limited to 'src/osmo_gsm_tester/process.py')
-rw-r--r--src/osmo_gsm_tester/process.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/osmo_gsm_tester/process.py b/src/osmo_gsm_tester/process.py
index 534cdba..fb5c6f6 100644
--- a/src/osmo_gsm_tester/process.py
+++ b/src/osmo_gsm_tester/process.py
@@ -236,25 +236,26 @@ class RemoteProcess(Process):
' '.join(self.popen_args))]
self.dbg(self.popen_args, dir=self.run_dir, conf=self.popen_kwargs)
+def run_proc_sync(proc):
+ try:
+ proc.launch()
+ proc.wait()
+ except Exception as e:
+ proc.terminate()
+ raise e
+ if proc.result != 0:
+ log.ctx(proc)
+ raise log.Error('Exited in error')
def run_local_sync(run_dir, name, popen_args):
run_dir =run_dir.new_dir(name)
proc = Process(name, run_dir, popen_args)
- proc.launch()
- proc.wait()
- if proc.result != 0:
- log.ctx(proc)
- raise log.Error('Exited in error')
+ run_proc_sync(proc)
def run_remote_sync(run_dir, remote_user, remote_addr, name, popen_args, remote_cwd=None):
run_dir = run_dir.new_dir(name)
- proc = RemoteProcess(name, run_dir, remote_user, remote_addr, remote_cwd,
- popen_args)
- proc.launch()
- proc.wait()
- if proc.result != 0:
- log.ctx(proc)
- raise log.Error('Exited in error')
+ proc = RemoteProcess(name, run_dir, remote_user, remote_addr, remote_cwd, popen_args)
+ run_proc_sync(proc)
def scp(run_dir, remote_user, remote_addr, name, local_path, remote_path):
run_local_sync(run_dir, name, ('scp', '-r', local_path, '%s@%s:%s' % (remote_user, remote_addr, remote_path)))