I've read about implementing Multiprocessing (reference) and am wondering the best practice for when one function needs to be offset because it depends on the other process.
The first process records sensor data. The second process analyzes that data. I want the first process to run continuously so I don't have gaps in my sensor readings. The analyzing takes a little less time than the recording. My problem is that I can't kick off the second process until at least one iteration of the recording function has finished or else there won't be data to read.
Should I offset the loop or should I make some kind of queue for the analyzing function?
This would be my offsetting approach:
from multiprocessing import Process
if __name__ == '__main__':
X = variableHoldingOutputFileNamefromRecordingFunc
recordingFunc() # first loop
while (True)
p1 = Process(target=recordingFunc)
p1.start()
p2 = Process(target=analyzingFunc, args=X)
p2.start()
p1.join()
p2.join()
I am not sure how to make a queue, but I suppose I could the recordingFunc add its output file names to a list and then have the analyzingFunc go thru that list...
Sorry I am a noob. I am told this question should be more focused but I am not sure in what way the moderators mean.