Skip to content

Instantly share code, notes, and snippets.

@DeastinY
Created May 16, 2019 11:57
Show Gist options
  • Save DeastinY/4e81f85103daab472f0e507471dfd934 to your computer and use it in GitHub Desktop.
Save DeastinY/4e81f85103daab472f0e507471dfd934 to your computer and use it in GitHub Desktop.
import time
from multiprocessing import Pool, cpu_count
def my_func(i):
time.sleep(1)
return i
print(cpu_count())
with Pool(cpu_count()) as pool:
results = pool.map(my_func, range(50))
print(results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment