[issue3792] Module variable overridden in child processes with multiprocessing

Amaury Forgeot d'Arc report at bugs.python.org
Sat Sep 6 14:46:38 CEST 2008


Amaury Forgeot d'Arc <amauryfa at gmail.com> added the comment:

Well, I get the OP's expected result on windows:

C:\dev\python\trunk>PCbuild\python_d t.py
Got 'p' of Correct
C:\dev\python\trunk>PCbuild\python_d t.py -m
Got 'p' of Correct

This is easy to explain: on Unix, the forked process has a copy of the
memory and reads the last value in the module. 
But on Windows, the freshly spawned process imports the module, and get
the initial value (since it does not enter the "__main__" block).

This is documented:
http://docs.python.org/dev/library/multiprocessing.html#windows , under
"Global Variables".

By the way, the Windows way may have some advantages for some uses.
Could the same method (start a new interpreter, import modules, copy
needed objects), be made available on Unix?

----------
nosy: +amaury.forgeotdarc

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


More information about the Python-bugs-list mailing list