Skip to content

Instantly share code, notes, and snippets.

@j-thepac
Created July 3, 2022 13:30
Show Gist options
  • Save j-thepac/ff92054fa6f5d580bf2a27da3351061f to your computer and use it in GitHub Desktop.
Save j-thepac/ff92054fa6f5d580bf2a27da3351061f to your computer and use it in GitHub Desktop.
multiprocess
import concurrent.futures
import time ,datetime
start = datetime.datetime.now()
def do_something(seconds):
print(f'Sleeping {seconds}')
time.sleep(seconds)
return f'Done Sleeping...{seconds}'
with concurrent.futures.ProcessPoolExecutor() as executor:
results = executor.map(do_something, [1,1])
for i in results:print(i)
print(datetime.datetime.now()-start) #01.003
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment