From b91d24f8d22bfcc1fa36a2ed7d2774e09dc69eb7 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Fri, 10 May 2019 22:08:18 +0200 Subject: [PATCH] more protection --- owrx/source.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/owrx/source.py b/owrx/source.py index fb98b80..c927d1a 100644 --- a/owrx/source.py +++ b/owrx/source.py @@ -88,6 +88,7 @@ class SdrSource(object): self.clients = [] self.spectrumClients = [] self.spectrumThread = None + self.process = None self.modificationLock = threading.Lock() # override these in subclasses as necessary @@ -184,13 +185,15 @@ class SdrSource(object): self.modificationLock.acquire() - self.spectrumThread.stop() + if self.spectrumThread is not None: + self.spectrumThread.stop() - try: - os.killpg(os.getpgid(self.process.pid), signal.SIGTERM) - except ProcessLookupError: - # been killed by something else, ignore - pass + if self.process is not None: + try: + os.killpg(os.getpgid(self.process.pid), signal.SIGTERM) + except ProcessLookupError: + # been killed by something else, ignore + pass if self.monitor: self.monitor.join() self.sleepOnRestart()