pool map cycle - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: pool map cycle (/thread-17303.html) |
pool map cycle - skorost5 - Apr-05-2019 Trying to run twice pool map cycle. from multiprocessing import Pool b=["0","0","0","0","0","0"] def f(c): b[5]=c return b for i1 in range(1,3): if __name__ == '__main__': p = Pool(1) print(p.map(f, ["f", "n","x"])) b[2]="3"The program displays the following response: And I need it to be: Why does the first line print 3 ?
RE: pool map cycle - scidam - Apr-06-2019 I just ran your code and got: So, I cann't reproduce the problem.
RE: pool map cycle - skorost5 - Apr-06-2019 Thank you. One last question. What version of Python did you use? I can not achieve this result. RE: pool map cycle - scidam - Apr-06-2019 Python 3.7.1 [GCC 7.3.0] RE: pool map cycle - skorost5 - Apr-07-2019 Installed the same version, but not yet displays:
maybe the problem is in the encoding try to test your code with the addition of a string of ASCII # -*- coding: ASCII -*- # -*- coding: ASCII -*- from multiprocessing import Pool b=["0","0","0","0","0","0"] def f(c): b[5]=c return b for i1 in range(1,3): if __name__ == '__main__': p = Pool(1) print(p.map(f, ["t", "n","x"])) b[2]="3" RE: pool map cycle - skorost5 - Apr-07-2019 tried to execute the same code on the website https://repl.it/languages/python3 and it worked. This site uses Python interpreter 3.6.1 (default, Dec 2015, 13:05:11)[GCC 4.8.2] on linux and I tried to run the code on windows so it did not work |