Eryk Sun added the comment:

Change the last print to test the exit code, as follows:

    if p.exitcode != 0:
        print('Child failed with exit code:', p.exitcode)
    else:
        print(num.value)
        print(arr[:])

Note that when you fail to limit creating a new process to just the "__main__" 
script, the child process ends up failing. Run it in a command prompt to see 
the following RuntimeError from the child:

    RuntimeError:
            An attempt has been made to start a new process before the
            current process has finished its bootstrapping phase.

            This probably means that you are not using fork to start your
            child processes and you have forgotten to use the proper idiom
            in the main module:

                if __name__ == '__main__':
                    freeze_support()
                    ...

            The "freeze_support()" line can be omitted if the program
            is not going to be frozen to produce an executable.

Since there's no fork() in the Windows API (the NT kernel actually implements 
forking for other subsystems such as the old POSIX system and the new Linux 
system, but the Windows API wasn't designed for it), multiprocessing has to 
import the main script in a new process, in which case the __name__ is not 
"__main__". But since you're not checking the __name__, it ends up trying to 
start another Process instance. You're lucky that this API has been made smart 
enough to detect this. It used to blow up recursively creating processes.

----------
nosy: +eryksun
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29345>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to