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

20 lines
392 B
Markdown

#code
- ` import multiprocessing, tqdm # for loading bar`
- ```python
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.