I am writing code for testing existence of bucket in different clouds. For parallel execution have created 3 pools and using imap to call and run all three in parallel. But once one pool is completed it does not wait for other pool to complete and the main program prints the result by executing remaining part of the program. The problem arises on Linux only It is working fine for windows using imap()
Have tried using map, imap and imap_unordered.
from multiprocessing.dummy import Pool
def cloud1(bucket_name):
some code to fetch respective details
return
def cloud2(bucket_name):
some code to fetch respective details
return
def cloud3(bucket_name):
some code to fetch respective details
return
bucket_names = ["bucket1","bucket2","bucket3"] # A list to store Bucket names
#Calling all function using pool
p1=Pool(15)
p2=Pool(15)
p3=Pool(50)
results1=p1.imap(cloud1, bucket_names)
results2=p2.imap(cloud2, bucket_names)
results3=p3.imap(cloud3, bucket_names)
p1.close()
p1.join()
p2.close()
p2.join()
p3.close()
p3.join()
#Printing output
print(results1)
print(results2)
print(results3)
The code should wait for each pool to finish the execution and then print the output like it is doing in windows.