generated from Hazel/python-project
retries
This commit is contained in:
parent
a575134abc
commit
6743b939ad
@ -6,13 +6,10 @@ from . import cache
|
||||
|
||||
|
||||
def main():
|
||||
c = Connection(cache_enable=False, request_delay=3, rate_limit_status_codes={200})
|
||||
c = Connection(cache_enable=False, request_delay=1.5, rate_limit_status_codes={200})
|
||||
c.generate_headers()
|
||||
|
||||
print(c.get("http://ip.org/"))
|
||||
print(c.get("http://ip.org/"))
|
||||
print(c.get("http://ip.org/"))
|
||||
print(c.get("http://ip.org/"))
|
||||
|
||||
|
||||
def cli():
|
||||
|
@ -120,7 +120,8 @@ class Connection:
|
||||
self.last_request = time.time()
|
||||
|
||||
|
||||
# TODO validate response and retrying if necessary
|
||||
if not self.validate_response(response):
|
||||
return self.send_request(request, attempt=attempt+1)
|
||||
|
||||
if self.cache_enable:
|
||||
cache.write_cache(url, response)
|
||||
|
Loading…
x
Reference in New Issue
Block a user