Last active
October 12, 2018 06:47
-
-
Save theSage21/25691a832286773733d268f3ab2f8ad0 to your computer and use it in GitHub Desktop.
Tqdm + pool.imap_unordered
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tqdm import tqdm | |
from multiprocessing import Pool | |
def myfn(x): | |
return x ** 2 | |
with Pool() as pool: | |
args = list(range(1_000_000)) | |
work = pool.imap_unordered(myfn, args, chunksize=100) | |
results = [] | |
for out in tqdm(work, total=len(args)): | |
results.append(out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment