apache - Python: Running multiple http requests concurrently based on an initial request? -


currently trying fetch api has 2 endpoints:

get /allusers  /user_detail/{id} 

in order details of users, have call get /allusers, , loop through ids call get /user_detail/{id} endpoint 1 1. wonder if it's possible have multiple get /user_detail/{id} calls running @ same time? or perhaps there better approach?

this sounds great use case grequests

import grequests  urls = [f'http://example.com/user_detail/{id}' id in range(10)]  rs = (grequests.get(u) u in urls) responses = grequests.map(rs) 

edit: example processing responses retrieve json could:

data = [] response in responses:     data.append(response.json()) 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -