| 123456789101112131415161718192021222324252627282930313233343536 |
- # coding:utf-8
- # import os
- # print('Process (%s) start...' % os.getpid())
- # pid = os.fork()
- # if pid == 0:
- # print('I am child process (%s) and my parent is %s.' % (os.getpid(), os.getppid()))
- # else:
- # print('I (%s) just created a child process (%s).' % (os.getpid(), pid))
- from multiprocessing import Process
- import time
- import os
- def run_proc(name):
- print('Run child process %s (%s)...' % (name, os.getpid()))
- time.sleep(99)
- if __name__ == '__main__':
- print('Parent process %s.' % os.getpid())
- p = Process(target=run_proc, args=('test',))
- print('Child process will start.')
- p.start()
- p.join()
- print('Child process end.')
|