delay startup of background services to increase user interface response
This commit is contained in:
parent
8f7f34c190
commit
d1eaab7711
@ -30,12 +30,13 @@ class ServiceHandler(object):
|
|||||||
def __init__(self, source):
|
def __init__(self, source):
|
||||||
self.services = []
|
self.services = []
|
||||||
self.source = source
|
self.source = source
|
||||||
|
self.startupTimer = None
|
||||||
self.source.addClient(self)
|
self.source.addClient(self)
|
||||||
self.source.getProps().collect("center_freq", "samp_rate").wire(self.onFrequencyChange)
|
self.source.getProps().collect("center_freq", "samp_rate").wire(self.onFrequencyChange)
|
||||||
self.updateServices()
|
self.scheduleServiceStartup()
|
||||||
|
|
||||||
def onSdrAvailable(self):
|
def onSdrAvailable(self):
|
||||||
self.updateServices()
|
self.scheduleServiceStartup()
|
||||||
|
|
||||||
def onSdrUnavailable(self):
|
def onSdrUnavailable(self):
|
||||||
self.stopServices()
|
self.stopServices()
|
||||||
@ -54,9 +55,16 @@ class ServiceHandler(object):
|
|||||||
service.start()
|
service.start()
|
||||||
|
|
||||||
def onFrequencyChange(self, key, value):
|
def onFrequencyChange(self, key, value):
|
||||||
|
self.stopServices()
|
||||||
if not self.source.isAvailable():
|
if not self.source.isAvailable():
|
||||||
return
|
return
|
||||||
self.updateServices()
|
self.scheduleServiceStartup()
|
||||||
|
|
||||||
|
def scheduleServiceStartup(self):
|
||||||
|
if self.startupTimer:
|
||||||
|
self.startupTimer.cancel()
|
||||||
|
self.startupTimer = threading.Timer(10, self.updateServices)
|
||||||
|
self.startupTimer.start()
|
||||||
|
|
||||||
def updateServices(self):
|
def updateServices(self):
|
||||||
logger.debug("re-scheduling services due to sdr changes")
|
logger.debug("re-scheduling services due to sdr changes")
|
||||||
|
Loading…
Reference in New Issue
Block a user