Created
September 25, 2016 21:14
-
-
Save gjreda/d5f0b41662c7c721148cb63f81baa50f to your computer and use it in GitHub Desktop.
example of using Python3's concurrent.futures module
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
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