This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mnewman
Recipients georg.brandl, mnewman
Date 2009-07-04.14:58:42
SpamBayes Score 5.55112e-17
Marked as misclassified No
Message-id <>
The " The Process class" section of the multiprocessing
has errors in both examples.

The first example needs the indentation fixed on the "from" and "if"
lines (remove the leading spaces).

The second example has two issues: print syntax needs be updated from
2.0 to 3.0 syntax. Also, getppid is not available on win32 platforms.
Below is a corrected example, which I tested successfully on on win32
and linux:

# Python 3.1 (r31:73574, Jun 26 2009, 20:21:35) [MSC v.1500 32 bit
(Intel)] on win32
main line
module name: __main__
parent process: None
process id: 3216
function f
module name: __main__
parent process: 3216
process id: 3692
hello bob

# Python 3.0.1 (r301:69556, Jun  6 2009, 21:34:43) [GCC 4.3.2] on linux2
mike@www:~/files$ python3.0
main line
module name: __main__
parent process: 19853
process id: 22544
function f
module name: __main__
parent process: 22544
process id: 22545
hello bob

# Start of corrected example:

from multiprocessing import Process, current_process
from sys import platform
import os

def info(title):
    print('module name:', __name__)
    if platform == 'win32':
      print('parent process:', current_process()._parent_pid)
      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',))

# End of corrected example.

I also saw this online:
"os.getppid on Windows"
But the license of the code is not clear, and it would make the example
too confusing to insert in.

Another reference:
"Multiprocessing docs are not 3.0-ready"
Looks like some print statements fixed back then, but not sure why the
examples mentioned here were not fixed.
Date User Action Args
2009-07-04 14:58:45mnewmansetrecipients: + mnewman, georg.brandl
2009-07-04 14:58:45mnewmansetmessageid: <>
2009-07-04 14:58:43mnewmanlinkissue6417 messages
2009-07-04 14:58:42mnewmancreate