Skip to content

Instantly share code, notes, and snippets.

Created January 4, 2013 19:52
Show Gist options
  • Select an option

  • Save anonymous/4455376 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/4455376 to your computer and use it in GitHub Desktop.
futures in python for list.pop()
import concurrent.futures
ml = [i for i in range(0,100)]
lr = []
def nothing():
pass
print("Beginning: ", len(ml))
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
future_quadrat = { executor.submit(ml.pop): i for i in range(len(ml))}
for future in concurrent.futures.as_completed(future_quadrat):
q = future_quadrat[future]
lr.append(q)
print(q, future.result())
print("End: ml: ", len(ml), "lr: ", len(lr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment