[New-bugs-announce] [issue4193] Multiprocessing example

David W. Lambert report at bugs.python.org
Fri Oct 24 18:54:37 CEST 2008


New submission from David W. Lambert <lambertdw at corning.com>:

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

----------
assignee: georg.brandl
components: Documentation
messages: 75172
nosy: LambertDW, georg.brandl
severity: normal
status: open
title: Multiprocessing example
type: feature request
versions: Python 3.0

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4193>
_______________________________________


More information about the New-bugs-announce mailing list