use better locking for the service startup/shutdown

This commit is contained in:
Jakob Ketterl 2020-07-30 21:35:31 +02:00
parent c8e5b4f822
commit 7ea8c8f7c6

View File

@ -61,7 +61,7 @@ class Js8ServiceOutput(ServiceOutput):
class ServiceHandler(object): class ServiceHandler(object):
def __init__(self, source): def __init__(self, source):
self.lock = threading.Lock() self.lock = threading.RLock()
self.services = [] self.services = []
self.source = source self.source = source
self.startupTimer = None self.startupTimer = None
@ -124,6 +124,7 @@ class ServiceHandler(object):
self.startupTimer.start() self.startupTimer.start()
def updateServices(self): def updateServices(self):
with self.lock:
logger.debug("re-scheduling services due to sdr changes") logger.debug("re-scheduling services due to sdr changes")
self.stopServices() self.stopServices()
if not self.source.isAvailable(): if not self.source.isAvailable():
@ -146,9 +147,6 @@ class ServiceHandler(object):
logger.debug("no services available") logger.debug("no services available")
return return
with self.lock:
self.services = []
groups = self.optimizeResampling(dials, sr) groups = self.optimizeResampling(dials, sr)
if groups is None: if groups is None:
for dial in dials: for dial in dials: