python multiprocessing详解

  1. Process类的使用

“`
import os
from multiprocessing import Process

def info(title):
print title
print ‘module name:’, name
if hasattr(os, ‘getppid’): # only available on Unix
print ‘parent process:’, os.getppid()
print ‘process id:’, os.getpid()

def f(name):
info(‘function f’)
print ‘hello’, name

if name == ‘main‘:
info(‘main line’)
p = Process(target=f, args=(‘bob’,))
p.start()
p.join()

未完待续

猜你喜欢

转载自blog.csdn.net/python_tty/article/details/79481210