Skip to content

Instantly share code, notes, and snippets.

@fauxneticien
Created November 10, 2022 19:05
Show Gist options
  • Save fauxneticien/473810ffb3ede77506d1d21dae5457ef to your computer and use it in GitHub Desktop.
Save fauxneticien/473810ffb3ede77506d1d21dae5457ef to your computer and use it in GitHub Desktop.
MWE for tqdm multiprocessing
from multiprocessing import Pool
import tqdm
import time
def _foo(my_number):
square = my_number * my_number
time.sleep(1)
return square
if __name__ == '__main__':
with Pool(2) as p:
r = list(tqdm.tqdm(p.imap(_foo, range(30)), total=30))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment