improve variable handling

This commit is contained in:
Jakob Ketterl 2020-02-27 18:50:53 +01:00
parent 388218f9df
commit c325368be8

View File

@ -115,6 +115,7 @@ class dsp(object):
self.is_service = False self.is_service = False
self.direwolf_config = None self.direwolf_config = None
self.direwolf_port = None self.direwolf_port = None
self.process = None
def set_service(self, flag=True): def set_service(self, flag=True):
self.is_service = flag self.is_service = flag
@ -744,9 +745,10 @@ class dsp(object):
def stop(self): def stop(self):
self.modification_lock.acquire() self.modification_lock.acquire()
self.running = False self.running = False
if hasattr(self, "process"): if self.process is not None:
try: try:
os.killpg(os.getpgid(self.process.pid), signal.SIGTERM) os.killpg(os.getpgid(self.process.pid), signal.SIGTERM)
self.process = None
except ProcessLookupError: except ProcessLookupError:
# been killed by something else, ignore # been killed by something else, ignore
pass pass
@ -764,4 +766,3 @@ class dsp(object):
def __del__(self): def __del__(self):
self.stop() self.stop()
del self.process