concurrency examples

This commit is contained in:
Luciano Ramalho
2015-02-02 14:07:35 -02:00
parent ab6ce5b6a4
commit 70163d2deb
13 changed files with 131 additions and 56 deletions

View File

@@ -7,13 +7,12 @@ from concurrent import futures
from daypicts import main, get_picture_url, NoPictureForDate
MAX_NUM_THREADS = 400
GLOBAL_TIMEOUT = 300 # seconds
MAX_CONCURRENT_REQUESTS = 30
def get_picture_urls(dates, verbose=False):
num_threads = min(len(dates), MAX_NUM_THREADS)
pool = futures.ThreadPoolExecutor(num_threads)
pool = futures.ThreadPoolExecutor(MAX_CONCURRENT_REQUESTS)
pending = {}
for date in dates: