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 tim.peters
Recipients Naftali.Harris, sbt, tim.peters
Date 2014-02-26.04:30:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1393389036.35.0.316175246214.issue20775@psf.upfronthosting.co.za>
In-reply-to
Content
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().
History
Date User Action Args
2014-02-26 04:30:36tim.peterssetrecipients: + tim.peters, sbt, Naftali.Harris
2014-02-26 04:30:36tim.peterssetmessageid: <1393389036.35.0.316175246214.issue20775@psf.upfronthosting.co.za>
2014-02-26 04:30:36tim.peterslinkissue20775 messages
2014-02-26 04:30:35tim.peterscreate