Skip to content

Instantly share code, notes, and snippets.

@AdrianAcala
Created February 26, 2020 18:40
Show Gist options
  • Save AdrianAcala/32194a48c921a68405228dfaf9092d0f to your computer and use it in GitHub Desktop.
Save AdrianAcala/32194a48c921a68405228dfaf9092d0f to your computer and use it in GitHub Desktop.
Python multithreading pool example
import multiprocessing
def func(x):
print(x*x)
num_of_workers = multiprocessing.cpu_count()
pool = multiprocessing.Pool(num_of_workers)
for i in range(1,10):
pool.apply_async(func, args=(i,))
pool.close()
pool.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment