quartz/content/Obsidian Vault/remnote backup/How to use multiprocessing python.md
2022-06-07 14:39:39 -06:00

391 B

#code

  • import multiprocessing, tqdm # for loading bar

collect_results = []

def replicate(input): # do the thing return thing

for x in tqdm(pool.imap(replicate, enumerate(vector)), total=len(vector)): collect_results.append(x)

pool.close() pool.join()

- 
- this also shows a nice loading bar showing your progress, and maintains the order of the original input.