Issue 4193: Multiprocessing example - Python tracker (original) (raw)

http://docs.python.org/dev/3.0/library/multiprocessing.html

I'm sure the examples have been thoughtfully contrived. Still, this seems instructive without adding much complexity. I'd change the first "trivial example" to

########################################### from multiprocessing import Process import os

def info(title): print(title) print('module name:',name) print('parent process:',os.getppid()) print('process id:',os.getpid()) print()

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() ###########################################

with output similar to

main line module name: main parent process: 12926 process id: 17002

function f module name: main parent process: 17002 process id: 17004

hello bob