import multiprocessing from multiprocessing.spawn import freeze_support def print1(): print("Print1") def print2(num1): print("Print2 : {0}".format(num1)) def print3(num1, num2): print("Print3 : {0}, {1}".format(num1, num2)) if __name__ == '__main__': # Run code for process object if this in not the main process freeze_support() # creating processes p1 = multiprocessing.Process(target=print1) p2 = multiprocessing.Process(target=print2, args=(10,)) p3 = multiprocessing.Process(target=print3, args=(10, 20,)) # starting processes p1.start() p2.start() p3.start() # wait until processes are finished p1.join() p2.join() p3.join()
References
https://www.geeksforgeeks.org/multiprocessing-python-set-1/
https://stackoverflow.com/questions/8804830/python-multiprocessing-picklingerror-cant-pickle-type-function