classification
Title: Multiprocessing example
Type: enhancement Stage:
Components: Documentation Versions: Python 3.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jnoller Nosy List: LambertDW, georg.brandl, jnoller
Priority: normal Keywords:

Created on 2008-10-24 16:54 by LambertDW, last changed 2008-11-28 18:48 by jnoller. This issue is now closed.

Messages (2)
msg75172 - (view) Author: David W. Lambert (LambertDW) Date: 2008-10-24 16:54
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
msg76545 - (view) Author: Jesse Noller (jnoller) * (Python committer) Date: 2008-11-28 18:48
Added in r67419 on trunk, merged to py3k and 2.6.1
History
Date User Action Args
2008-11-28 18:48:13jnollersetstatus: open -> closed
resolution: fixed
messages: + msg76545
2008-11-22 08:55:01georg.brandlsetassignee: georg.brandl -> jnoller
nosy: + jnoller
2008-10-24 16:54:36LambertDWcreate