From feba7351f156d27c7821d883aeed1df40f4f619b Mon Sep 17 00:00:00 2001 From: Mark Jessop Date: Thu, 24 May 2018 21:44:49 +0930 Subject: [PATCH] Restructured decoder subprocess kill section a bit. --- auto_rx/autorx/decode.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/auto_rx/autorx/decode.py b/auto_rx/autorx/decode.py index 2388019..f980621 100644 --- a/auto_rx/autorx/decode.py +++ b/auto_rx/autorx/decode.py @@ -284,14 +284,17 @@ class SondeDecoder(object): try: # Stop the async reader self.async_reader.stop() - # Send a SIGKILL to the subprocess PID via OS. This may fail if the above line worked. + # Send a SIGKILL to the subprocess PID via OS. try: os.killpg(os.getpgid(self.decode_process.pid), signal.SIGKILL) except Exception as e: - self.log_debug("SIGKILL via OS failed.") + self.log_debug("SIGKILL via os.killpg failed. - %s" % str(e)) time.sleep(1) - # Send a SIGKILL via subprocess - self.decode_process.kill() + try: + # Send a SIGKILL via subprocess + self.decode_process.kill() + except Exception as e: + self.log_debug("SIGKILL via subprocess.kill failed - %s" % str(e)) # Finally, join the async reader. self.async_reader.join()