Created
January 28, 2020 10:46
-
-
Save eriky/a311abd2e1433dd7ff2cbe5ed5d95968 to your computer and use it in GitHub Desktop.
This file contains 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
from concurrent.futures import ThreadPoolExecutor | |
from time import sleep | |
def return_after_5_secs(message): | |
sleep(5) | |
return message | |
pool = ThreadPoolExecutor(3) | |
future = pool.submit(return_after_5_secs, | |
("Hello world")) | |
print(future.done()) | |
# False | |
sleep(5) | |
print(future.done()) | |
# True | |
print(future.result()) | |
# Hello World |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment