Created
November 2, 2021 09:21
-
-
Save VehpuS/1b9891a84ce4cbeeee28b48f340262c2 to your computer and use it in GitHub Desktop.
Proof that concurrent.future's executor.map returns values in order
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 time | |
import random | |
import concurrent.futures | |
e = concurrent.futures.ThreadPoolExecutor(4) | |
s = range(10) | |
def sleep_and_return(i): | |
time.sleep(random.randint(3,7)) | |
return i | |
for i in e.map(sleep_and_return, s): | |
print(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment