Skip to content

Instantly share code, notes, and snippets.

@hamelsmu
Created July 2, 2020 18:55
Show Gist options
  • Save hamelsmu/95d372937f4df32c9e73b8ccb423ff1b to your computer and use it in GitHub Desktop.
Save hamelsmu/95d372937f4df32c9e73b8ccb423ff1b to your computer and use it in GitHub Desktop.
from multiprocessing import Pool
from time import sleep
def f(x):
sleep(1000) # simulate some computation
return x*x
if __name__ == '__main__':
with Pool(8) as p:
print(p.map(f, range(8)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment