Pau Espin Pedrol has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11459 )

Change subject: process: Make sure sync process is terminated if ogt is stopped
......................................................................

process: Make sure sync process is terminated if ogt is stopped

Change-Id: Iecdac96ea576a312be2a6c6b6799e249074687ef
---
M src/osmo_gsm_tester/process.py
1 file changed, 13 insertions(+), 12 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



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 @@
                                      ' '.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)))

--
To view, visit https://gerrit.osmocom.org/11459
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iecdac96ea576a312be2a6c6b6799e249074687ef
Gerrit-Change-Number: 11459
Gerrit-PatchSet: 2
Gerrit-Owner: Pau Espin Pedrol <pes...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pes...@sysmocom.de>

Reply via email to