Skip to content

Instantly share code, notes, and snippets.

@hholst80
Created June 26, 2017 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hholst80/eaff5949fee750d20f67a9a9ca4a9427 to your computer and use it in GitHub Desktop.
Save hholst80/eaff5949fee750d20f67a9a9ca4a9427 to your computer and use it in GitHub Desktop.
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