New submission from Naftali Harris: Hi everyone,
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" def f(ignored): print(name) def main(): global name p = Pool(3) name = "Updated" p.map(f, range(3)) if __name__ == "__main__": main() $ python reproduces.py Not Updated Not Updated Not Updated 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, Naftali ---------- components: Library (Lib) files: reproduces.py messages: 212221 nosy: Naftali.Harris priority: normal severity: normal status: open title: Modifications to global variables ignored after instantiating multiprocessing.Pool type: behavior 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 <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