Created
July 3, 2022 13:20
-
-
Save j-thepac/f9e11eef7fe0e81995fa4b6484794d6e to your computer and use it in GitHub Desktop.
multithread
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.ThreadPoolExecutor() 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