From 343b15fc78656a6a9e50c8fca75fc7dbb72b7265 Mon Sep 17 00:00:00 2001 From: Dominic Amato Date: Thu, 2 Jan 2020 15:20:52 -0600 Subject: [PATCH] wait for the process to be terminated --- Hologram/Network/Modem/ModemMode/PPP.py | 5 ++++- scripts/hologram_modem.py | 4 +++- scripts/hologram_network.py | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Hologram/Network/Modem/ModemMode/PPP.py b/Hologram/Network/Modem/ModemMode/PPP.py index 82b8cbd..f614a92 100755 --- a/Hologram/Network/Modem/ModemMode/PPP.py +++ b/Hologram/Network/Modem/ModemMode/PPP.py @@ -78,7 +78,10 @@ def __shut_down_existing_ppp_session(self): for pid in pid_list: self.logger.info('Killing pid %s that currently have an active PPP session', pid) - psutil.Process(pid).terminate() + process = psutil.Process(pid) + process.terminate() + # Wait at least 10 seconds for the process to terminate + process.wait(10) def __check_for_existing_ppp_sessions(self): diff --git a/scripts/hologram_modem.py b/scripts/hologram_modem.py index a69c5aa..c918a3e 100644 --- a/scripts/hologram_modem.py +++ b/scripts/hologram_modem.py @@ -73,7 +73,9 @@ def run_modem_disconnect(args): if 'pppd' in pinfo['name']: print('Found existing PPP session on pid: %s' % pinfo['pid']) print('Killing pid %s now' % pinfo['pid']) - psutil.Process(pinfo['pid']).terminate() + process = psutil.Process(pinfo['pid']) + process.terminate() + process.wait() def run_modem_signal(args): cloud = CustomCloud(None, network='cellular') diff --git a/scripts/hologram_network.py b/scripts/hologram_network.py index 9dd07cc..6eec9e3 100644 --- a/scripts/hologram_network.py +++ b/scripts/hologram_network.py @@ -40,7 +40,9 @@ def run_network_disconnect(args): if 'pppd' in pinfo['name']: print('Found existing PPP session on pid: %s' % pinfo['pid']) print('Killing pid %s now' % pinfo['pid']) - psutil.Process(pinfo['pid']).terminate() + process = psutil.Process(pinfo['pid']) + process.terminate() + process.wait() _run_handlers = { 'network_connect': run_network_connect,