[New-bugs-announce] [issue20775] Modifications to global variables ignored after instantiating multiprocessing.Pool
report at bugs.python.org
Tue Feb 25 23:00:00 CET 2014
New submission from Naftali Harris:
It appears that if you use a global variable in a function that you pass to Pool.map, but modify that global variable after instantiating the Pool, then the modification will not be reflected when Pool.map calls that function.
Here's a short script, (also attached), that demonstrates what I mean:
$ cat reproduces.py
from multiprocessing import Pool
name = "Not Updated"
p = Pool(3)
name = "Updated"
if __name__ == "__main__":
$ python reproduces.py
If the `name = "Updated"' line is moved above the `p = Pool(3)' line, then the script will print "Updated" three times instead.
This behavior is present in versions 2.6, 2.7, 3.1, 3.2, 3.3, and 3.4. I run Linux Mint 14 (nadia), on an Intel i5-3210M processor (four cores).
Is this expected behavior?
Thanks very much,
components: Library (Lib)
title: Modifications to global variables ignored after instantiating multiprocessing.Pool
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file34223/reproduces.py
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce