I want to use the module multiprocessing to execute 2 functions at the same time but it doesn't work. the code in these two functions depends on the library of these two instruments, there has no matter with multiprocessing
import multiprocessing as mp
def mesure_rfb():
libc.StartMeas()
time.sleep(0.5)
while libc.Measuring() == -1:
time.sleep(1)
def mesure_nrt():
global ave,rev,chrono
my_nrt.zeroing()
my_nrt.setimeout(100000)
tstart = time.time()
b=2
ave,rev,chrono = my_nrt.measurement(times=b)
a=time.time()-tstart
print('measurement cost: ' , a,' s')
print('a measurement costs: ' , a/b,' s')
if __name__ == '__main__':
rfb = mp.Process(name='rfb measuring', target=mesure_rfb)
nrt = mp.Process(name='nrt measuring', target=mesure_nrt)
rfb.start()
nrt.start()
rfb.join()
nrt.join()
As soon as I run this part of my programme, it executes only the function mesure_nrt. I am quite new to python. Any help will be appreciated.