Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pool map cycle
#1
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:
Output:
[['0', '0', '3', '0', '0', 'f'], ['0', '0', '3', '0', '0', 'n'], ['0', '0', '3', '0', '0', 'x']] [['0', '0', '3', '0', '0', 'f'], ['0', '0', '3', '0', '0', 'n'], ['0', '0', '3', '0', '0', 'x']]
And I need it to be:
Output:
[['0', '0', '0', '0', '0', 'f'], ['0', '0', '0', '0', '0', 'n'], ['0', '0', '0', '0', '0', 'x']] [['0', '0', '3', '0', '0', 'f'], ['0', '0', '3', '0', '0', 'n'], ['0', '0', '3', '0', '0', 'x']]
Why does the first line print 3 ?
Reply


Messages In This Thread
pool map cycle - by skorost5 - Apr-05-2019, 04:27 PM
RE: pool map cycle - by scidam - Apr-06-2019, 10:20 AM
RE: pool map cycle - by skorost5 - Apr-06-2019, 06:07 PM
RE: pool map cycle - by scidam - Apr-06-2019, 11:17 PM
RE: pool map cycle - by skorost5 - Apr-07-2019, 08:11 AM
RE: pool map cycle - by skorost5 - Apr-07-2019, 09:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Writing a cycle to find the nearest point from the array Tysrusko 0 196 May-10-2024, 11:49 AM
Last Post: Tysrusko
  Multiprocessing Pool Multiple Instances How to Kill by Pool ID sunny9495 0 802 Nov-16-2022, 05:57 AM
Last Post: sunny9495
  Need to fix SyntaxError in cycle try alexfrol86 14 3,302 Mar-27-2022, 07:53 AM
Last Post: stevendaprano
  Pool multiprocessing - know current status in loop? korenron 0 1,670 Jul-28-2021, 08:49 AM
Last Post: korenron
  pool mysql error - not catch by try\except? korenron 1 2,193 Jul-05-2021, 11:26 AM
Last Post: ibreeden
  Trying to cycle through a list of charcters pooky2483 12 4,644 Sep-28-2020, 06:55 AM
Last Post: pooky2483
  <while> cycle is not interrupted when using the <random>module ShityCoder 3 2,254 Sep-04-2020, 04:05 PM
Last Post: ShityCoder
  Cycle of numpy variables Zero01 0 1,586 Jul-31-2020, 11:58 AM
Last Post: Zero01
  stop cycle while windows11 1 2,080 May-16-2020, 03:17 PM
Last Post: deanhystad
  Process (pool,map) strange behaviour maverick76 1 1,978 Feb-03-2020, 02:43 PM
Last Post: maverick76

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020