Skip to content

Instantly share code, notes, and snippets.

@gjreda
Created September 25, 2016 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gjreda/d5f0b41662c7c721148cb63f81baa50f to your computer and use it in GitHub Desktop.
Save gjreda/d5f0b41662c7c721148cb63f81baa50f to your computer and use it in GitHub Desktop.
example of using Python3's concurrent.futures module
from concurrent.futures import ProcessPoolExecutor
import concurrent.futures
from halas.parsers import boxscore
GAMES = [ ... ]
results = []
with ProcessPoolExecutor(max_workers=4) as executor:
future_results = {executor.submit(boxscore, game):
game for game in GAMES}
for future in concurrent.futures.as_completed(future_results):
print('completed', future_results[future])
box = future.result()
results.append(box)
print('results', len(results))
print('done')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment