I am trying to execute the following code:
from multiprocessing import Pool
def f(x):
return x
if __name__ == '__main__':
p = Pool(5)
print(p.map(f, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13]))
As I understand it, 5 processors get 0, 1, 2, 3, 4to perform operations. If processor 1 shuts down, does it receive 5immediately while the rest of the processors are busy 1,2,3,4, or does the code end for all processors, so the next batch will receive together 5, 6, 7, 8, 9and so on. If later happens, how to implement the above code so that when the processors are idle, it will be assigned a new task?
How to check implementation?
Zanam source
share