Skip to content

Instantly share code, notes, and snippets.

@VehpuS
Created November 2, 2021 09:21
Show Gist options
  • Save VehpuS/1b9891a84ce4cbeeee28b48f340262c2 to your computer and use it in GitHub Desktop.
Save VehpuS/1b9891a84ce4cbeeee28b48f340262c2 to your computer and use it in GitHub Desktop.
Proof that concurrent.future's executor.map returns values in order
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