Created
July 3, 2022 13:30
-
-
Save j-thepac/ff92054fa6f5d580bf2a27da3351061f to your computer and use it in GitHub Desktop.
multiprocess
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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