I recently came across some internal code at my workplace that uses the grequests library to make its HTTP requests.
However, as I was looking through the code, I noticed that the program only ever sends a single request at a time. For instance, consider the following function:
def run(self, uris):
# Create the request objects
reqs = [grequests.get(uri) for uri in uris]
# Send the requests out, wait for them to complete.
results = grequests.map(reqs, size=10)
...
In all instances that call this function, only one uri is ever passed to the function. In other words, all calls to this run()
function look like:
run([myURI])
Because I am new to using grequests, would this really offer any advantage over the traditional requests library? It would seem as though using grequests here just overcomplicates the code.
Would there ever be a case in which using grequests in this context would ever perform better than using plain old requests?