synchronize scheduler access
This commit is contained in:
parent
3814767e28
commit
6f983ccb6b
@ -90,6 +90,7 @@ class WsjtChopper(threading.Thread):
|
|||||||
(self.wavefilename, self.wavefile) = self.getWaveFile()
|
(self.wavefilename, self.wavefile) = self.getWaveFile()
|
||||||
self.switchingLock = threading.Lock()
|
self.switchingLock = threading.Lock()
|
||||||
self.scheduler = sched.scheduler(time.time, time.sleep)
|
self.scheduler = sched.scheduler(time.time, time.sleep)
|
||||||
|
self.schedulerLock = threading.Lock()
|
||||||
(self.outputReader, self.outputWriter) = Pipe()
|
(self.outputReader, self.outputWriter) = Pipe()
|
||||||
self.doRun = True
|
self.doRun = True
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -118,11 +119,13 @@ class WsjtChopper(threading.Thread):
|
|||||||
threading.Thread(target=self.scheduler.run).start()
|
threading.Thread(target=self.scheduler.run).start()
|
||||||
|
|
||||||
def emptyScheduler(self):
|
def emptyScheduler(self):
|
||||||
for event in self.scheduler.queue:
|
with self.schedulerLock:
|
||||||
self.scheduler.cancel(event)
|
for event in self.scheduler.queue:
|
||||||
|
self.scheduler.cancel(event)
|
||||||
|
|
||||||
def _scheduleNextSwitch(self):
|
def _scheduleNextSwitch(self):
|
||||||
self.scheduler.enterabs(self.getNextDecodingTime(), 1, self.switchFiles)
|
with self.schedulerLock:
|
||||||
|
self.scheduler.enterabs(self.getNextDecodingTime(), 1, self.switchFiles)
|
||||||
|
|
||||||
def switchFiles(self):
|
def switchFiles(self):
|
||||||
self.switchingLock.acquire()
|
self.switchingLock.acquire()
|
||||||
|
Loading…
Reference in New Issue
Block a user