ross / requests-futures

Asynchronous Python HTTP Requests for Humans using Futures
Other
2.11k stars 152 forks source link

How do you retry a timed-out request? #19

Closed aligajani closed 10 years ago

aligajani commented 10 years ago

I am current using this in this constructor, not sure if it correct:

self.session.mount('', HTTPAdapter(max_retries=5))

Also, how does one go about passing multiple parameters, current I have this:

self.session.get("".join(urls[i]), allow_redirects=True, timeout=10)

Thank you for your help and great library!

ross commented 10 years ago

the short answer is that requests-futures doesn't change requests's api. so whatever you do with standard requests should work exactly the same with requests-futures.

for the retries see this comment, looks like newer versions of requests have a global that can be set in addition to mentioning your method. http://stackoverflow.com/a/15431343

the parameters should work as you've passed them. if they work with plain requests.

aligajani commented 10 years ago

Thanks, I get that, but how does one go about retrying a single URL when I send 100 async requests.

ross commented 10 years ago

sorry not sure i follow. If you set things up to retry up to 5 times it should do that for any of the 100 async requests that fail/require it. i assume that happens behind the scenes inside of requests. you just won't see the results/callbacks for the failing requests until they succeed or exhaust their retries.