Tim Peters added the comment:

This is expected.  "global" has only to do with the visibility of a name within 
a module; it has nothing to do with visibility of mutations across processes.  
On a Linux-y system, executing Pool(3) creates 3 child processes, each of which 
sees a read-only *copy* of the state of the module at the time (the usual 
copy-on-write fork() semantics).  From that point on, nothing done in the main 
program can have any effect on the data values seen by the child processes, nor 
can anything done by a child process have any effect on the data values seen by 
the main program or by the other child processes, unless such data values are 
_explicitly_ shared via one of the cross-process data sharing mechanisms the 
multiprocessing module supports.

So, in your program, all child processes see name == "Not Updated", because 
that's the value `name` had at the time the processes were created.  The later

    name = "Updated"

changes the binding in the main program, and only in the main program.  If you 
want child processes to see the new value you should, e.g., pass `name` to f().

----------
nosy: +tim.peters

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

Reply via email to