Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import multiprocessing as mp
- process_list = []
- def pr1(test,test1):
- """
- @:param: test,test1 (Integer)
- process 1
- """
- print("Pr 1 prining... '"+str(test)+"','"+str(test1)+"' recieved...")
- def pr2():
- """
- process 2
- """
- print("Pr2 2 prining...")
- def pr3():
- """
- process 3
- """
- print("Pr3 3 prining...")
- def initprocess(function_name,args=()):
- """
- @:param function_name: name of the function
- @:param arg: Arguments to pass to function (tuple)
- Init processes and add it to the process list
- t"""
- global process_list
- if args == ():
- process_list.append(mp.Process(target=function_name))
- else:
- process_list.append(mp.Process(target=function_name,args=args))
- return
- def run():
- global process_list
- for process in process_list:
- process.start()
- def main():
- initprocess(pr1,(1,2,)) #Function with arguments
- initprocess(pr2) #Function without arguments
- initprocess(pr3)
- run()
- if __name__ == '__main__':
- main()
Add Comment
Please, Sign In to add comment