run multiple function with multiprocessing python

Solutions on MaxInterview for run multiple function with multiprocessing python by the best coders in the world

showing results for - "run multiple function with multiprocessing python"
Alexandra
27 Aug 2016
1from multiprocessing import Process
2import sys
3
4rocket = 0
5
6def func1():
7    global rocket
8    print ('start func1')
9    while rocket < sys.maxsize:
10        rocket += 1
11    print ('end func1')
12
13def func2():
14    global rocket
15    print ('start func2')
16    while rocket < sys.maxsize:
17        rocket += 1
18    print ('end func2')
19
20if __name__=='__main__':
21    p1 = Process(target=func1)
22    p1.start()
23    p2 = Process(target=func2)
24    p2.start()
25