Skip to content

Instantly share code, notes, and snippets.

@lukeorland
Last active October 20, 2017 14:25
Show Gist options
  • Save lukeorland/37642f0ee484d5f36c44db0c602c66c5 to your computer and use it in GitHub Desktop.
Save lukeorland/37642f0ee484d5f36c44db0c602c66c5 to your computer and use it in GitHub Desktop.
python3 concurrent ThreadPoolExecutor
#!/usr/bin/env python3
import concurrent.futures
import time
def slumber(seconds):
time.sleep(seconds)
print("slept %s seconds" % seconds)
def main():
durations = [1, 1, 2, 2, 3]
with concurrent.futures.ThreadPoolExecutor() as executor:
executor.map(slumber, durations)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment