1import multiprocessing
2
3def worker(num):
4 """ Worker procedure
5 """
6 print('Worker:', str(num))
7
8# Mind the "if" instruction!
9if __name__ == '__main__':
10 jobs = [] # list of jobs
11 jobs_num = 5 # number of workers
12 for i in range(jobs_num):
13 # Declare a new process and pass arguments to it
14 p1 = multiprocessing.Process(target=worker, args=(i,))
15 jobs.append(p1)
16 # Declare a new process and pass arguments to it
17 p2 = multiprocessing.Process(target=worker, args=(i+10,))
18 jobs.append(p2)
19 p1.start() # starting workers
20 p2.start() # starting workers