Skip to content

Instantly share code, notes, and snippets.

@kovalbogdan95
Created November 7, 2019 13:00
Show Gist options
  • Save kovalbogdan95/79c0ee790fa26f0fcd0dc54c6e5af3df to your computer and use it in GitHub Desktop.
Save kovalbogdan95/79c0ee790fa26f0fcd0dc54c6e5af3df to your computer and use it in GitHub Desktop.
Python Threading example
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"))
print(future.done())
sleep(5)
print(future.done())
print(future.result())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment