import multiprocessing as mp
from time import sleep
def log_gsr(g):
while True:
sleep(0.5)
print('gsr...')
if not g['gsr']:
break
return "good"
def log_eyetracking(g):
while True:
sleep(2)
print('eye tracking...')
if not g['eye']:
break
return "good"
def log_analog_input(g):
while True:
sleep(1)
print('analog input...')
if not g['analog']:
break
return "good"
if __name__ == '__main__':
g = mp.Manager().dict()
g['ready'] = False
g['gsr'] = True
g['eye'] = True
g['analog'] = True
gsr = mp.Process(target=log_gsr, args=(g,))
eyetracking = mp.Process(target=log_eyetracking, args=(g,))
analog = mp.Process(target=log_analog_input, args=(g,))
gsr.start()
eyetracking.start()
analog.start()
sleep(5)
g['gsr'] = False
g['eye'] = False
g['analog'] = False
a = gsr.join()
b = eyetracking.join()
c = analog.join()
print(gsr.value, eyetracking.value, analog.value)