Created
June 26, 2017 13:24
-
-
Save hholst80/eaff5949fee750d20f67a9a9ca4a9427 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
import time | |
import concurrent.futures | |
def worker(n): | |
time.sleep(n) | |
return 42 | |
with concurrent.futures.ThreadPoolExecutor() as extor: | |
future = extor.submit(worker, 3) | |
t0 = time.time() | |
result = future.result(timeout=1.0) | |
t1 = time.time() | |
print('dt={}'.format(t1-t0)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment