Last active
August 17, 2020 14:17
-
-
Save adminy/8e8415392fdc2486c6553b4330cb486a to your computer and use it in GitHub Desktop.
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
import concurrent.futures | |
with concurrent.futures.ThreadPoolExecutor(max_workers = 8) as executor: | |
tasks = range(20) | |
future_to_task = {executor.submit(lambda task: task ** 2, task): task for task in tasks} | |
for future in concurrent.futures.as_completed(future_to_task): | |
task = future_to_task[future] | |
output = future.result() | |
print(task, output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.