I am trying to make calls to several URLs at the same time using the grequests library for Python. The problem is that I do not quite understand the logic of grequests. Below is a sample (edited version) of my code:-
respArray = []
response = []
sessionvar = requests.Session()
sessionvar.trust_env = False
for each in range(0,len(urls)):
response.append(grequests.get(urls[each],session=sessionvar,cookies=cookiesArray[each]))
eachresp = grequests.map(response)
for r in eachresp:
respArray.append(r.json())
return respArray
My respArray
returns each individual array which was returned from the URLs.
When I run that array, it's as if each one is running on its own loop, and not concurrently. I am not getting how can I get it to run concurrently so that I get faster results.