mirror of
https://github.com/josegonzalez/python-github-backup.git
synced 2025-12-06 08:28:03 +01:00
Retry 3 times when the connection times out
This commit is contained in:
@@ -169,6 +169,7 @@ def retrieve_data(args, template, query_args=None, single_request=False):
|
|||||||
request.add_header('Authorization', 'Basic ' + auth)
|
request.add_header('Authorization', 'Basic ' + auth)
|
||||||
|
|
||||||
errors = []
|
errors = []
|
||||||
|
retry_timeout = 3
|
||||||
|
|
||||||
# We'll make requests in a loop so we can delay and retry in the case of rate-limiting
|
# We'll make requests in a loop so we can delay and retry in the case of rate-limiting
|
||||||
while True:
|
while True:
|
||||||
@@ -199,6 +200,16 @@ def retrieve_data(args, template, query_args=None, single_request=False):
|
|||||||
|
|
||||||
time.sleep(delta)
|
time.sleep(delta)
|
||||||
continue
|
continue
|
||||||
|
except urllib2.URLError:
|
||||||
|
# Incase of a connection timing out, we can retry a few time
|
||||||
|
# But we won't crash and not back-up the rest now
|
||||||
|
log_info('{} timed out'.format(template))
|
||||||
|
retry_timeout -= 1
|
||||||
|
|
||||||
|
if retry_timeout >= 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
log_error('{} timed out to much, skipping!')
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user