Last active
October 20, 2017 14:25
-
-
Save lukeorland/37642f0ee484d5f36c44db0c602c66c5 to your computer and use it in GitHub Desktop.
python3 concurrent ThreadPoolExecutor
This file contains hidden or 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
#!/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