I'm using Google's Distance Matrix API and wanted to get up to the rate limit of 1000 requests in 10 seconds without necessarily using the matrix component but just higher limit capability (directions API has 10 a second -> this in effect has 100 a second).
EDIT:
My main goal is to be able to exactly control how many requests I am filling a second (e.g do 800 in 10 seconds, or do 1000 in seconds) and ideally I would use this kind of pseudo code but I'm not sure:
pool = Pool() # Initialize a pool of max processes
start_time = time.time()
counter = 0
for one_url in URL_LIST:
counter += 1
# Once sent 1000 requests
if counter = 1000:
# If elapsed less than 10 seconds
if time.time() - start_time < 10 seconds:
# Wait until we hit 10 seconds
time.sleep(time.time() - start_time)
else:
#Taking more than 10 seconds
pass
#Reset counter and timer
start_time = time.time()
counter = 0
RESULTS_OUT = pool.map(GeocodeHandler, one_url)
pool.close() # This means that no more tasks will be added to the pool
pool.join() # This blocks the program till function is run on all the items