run different functions in parallel code example
Example: run different functions in parallel
def task_a():
print('this is task a')
def task_b():
print('this is task b')
def hello(msg):
print('Hello: %s'%(msg))
def run_parallel(*functions):
''' Run functions in parallel '''
from multiprocessing import Process
processes = []
for function in functions:
proc = Process(target=function)
proc.start()
processes.append(proc)
for proc in processes:
proc.join()
if __name__ == '__main__':
run_parallel(task_a(),task_b(),hello(msg="konstantinos"))