本文共 451 字,大约阅读时间需要 1 分钟。
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)) p = Process(target=run_proc, args=('test',)) print('Child process will start.') p.start() p.join() p = Pool(4) for i in range(5): p.apply_async(long_time_task, args=(i,)) print('Waiting for all subprocesses done...') p.close() p.join()
转载地址:http://hgyws.baihongyu.com/