protect the wave file switchover with a lock, since race conditions have
occured
This commit is contained in:
parent
2536d9f747
commit
cb0b950d34
@ -17,6 +17,7 @@ class Ft8Chopper(threading.Thread):
|
|||||||
def __init__(self, source):
|
def __init__(self, source):
|
||||||
self.source = source
|
self.source = source
|
||||||
(self.wavefilename, self.wavefile) = self.getWaveFile()
|
(self.wavefilename, self.wavefile) = self.getWaveFile()
|
||||||
|
self.switchingLock = threading.Lock()
|
||||||
self.scheduler = sched.scheduler(time.time, time.sleep)
|
self.scheduler = sched.scheduler(time.time, time.sleep)
|
||||||
self.fileQueue = []
|
self.fileQueue = []
|
||||||
(self.outputReader, self.outputWriter) = Pipe()
|
(self.outputReader, self.outputWriter) = Pipe()
|
||||||
@ -53,9 +54,11 @@ class Ft8Chopper(threading.Thread):
|
|||||||
self.scheduler.enterabs(self.getNextDecodingTime(), 1, self.switchFiles)
|
self.scheduler.enterabs(self.getNextDecodingTime(), 1, self.switchFiles)
|
||||||
|
|
||||||
def switchFiles(self):
|
def switchFiles(self):
|
||||||
|
self.switchingLock.acquire()
|
||||||
file = self.wavefile
|
file = self.wavefile
|
||||||
filename = self.wavefilename
|
filename = self.wavefilename
|
||||||
(self.wavefilename, self.wavefile) = self.getWaveFile()
|
(self.wavefilename, self.wavefile) = self.getWaveFile()
|
||||||
|
self.switchingLock.release()
|
||||||
|
|
||||||
file.close()
|
file.close()
|
||||||
self.fileQueue.append(filename)
|
self.fileQueue.append(filename)
|
||||||
@ -90,7 +93,9 @@ class Ft8Chopper(threading.Thread):
|
|||||||
logger.warning("zero read on ft8 chopper")
|
logger.warning("zero read on ft8 chopper")
|
||||||
self.doRun = False
|
self.doRun = False
|
||||||
else:
|
else:
|
||||||
|
self.switchingLock.acquire()
|
||||||
self.wavefile.writeframes(data)
|
self.wavefile.writeframes(data)
|
||||||
|
self.switchingLock.release()
|
||||||
|
|
||||||
self.decode()
|
self.decode()
|
||||||
logger.debug("FT8 chopper shutting down")
|
logger.debug("FT8 chopper shutting down")
|
||||||
|
Loading…
Reference in New Issue
Block a user