[熱情]

python multiprocessing 본문

Programming/python

python multiprocessing

rootkaien 2017. 1. 24. 17:57


python 3.5


from multiprocessing import Process
import time
import os

def func1(data):
    for i in range(0, 10):
        print(data)

def func2():
    for i in range(0, 10):
        print("bye~!")

def func3():
    print('module name : ', __name__)
    if hasattr(os, 'getppid'):
        print('parent process : ', os.getppid())
    print('process id : ', os.getpid())

if __name__ == "__main__":

    proc1 = Process(target=func1, args=("hello",))
    proc2 = Process(target=func2)
    proc3 = Process(target=func3)

    proc1.start()
    proc2.start()
    proc3.start()

    proc1.join()
    proc2.join()
    proc3.join() 


Comments