summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlinaro-cp.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/linaro-cp.py b/linaro-cp.py
index 1a1921a..24d8636 100755
--- a/linaro-cp.py
+++ b/linaro-cp.py
@@ -23,8 +23,8 @@ class API_v1(object):
self.build_info = build_info
self.api_key = api_key
- def _upload_data(self, url, data=None, files=None, headers=None, retry_count=3):
- while retry_count:
+ def _upload_data(self, url, data=None, files=None, headers=None, retry_count=5):
+ for x in range(retry_count):
try:
resp = requests.post(url, headers=headers, data=data, files=files, timeout=61)
if resp.status_code in (200, 201):
@@ -33,8 +33,8 @@ class API_v1(object):
print("Unsuccessful status:", resp.status_code)
except Exception as e:
print(e)
- print('Upload failed for %s, retrying in 2 seconds' % url)
- time.sleep(2)
+ print('Upload failed for %s, retry attempt %s' % url, x)
+ time.sleep(2 * x + 1)
retry_count -= 1
raise Exception("LLP request failed")
@@ -135,10 +135,10 @@ class API_v3(API_v1):
super(API_v3, self).__init__(server, build_info, api_key)
self.api_base = server + '/api/v3/publish/'
- def _put_s3(self, url, filename, mtype, retry_count=3):
+ def _put_s3(self, url, filename, mtype, retry_count=5):
size = os.path.getsize(filename)
headers = {'Content-Type': mtype, 'Content-Length': str(size)}
- while retry_count:
+ for x in range(retry_count):
try:
with open(filename, 'rb') as f:
resp = requests.put(url, headers=headers, data=f, timeout=61)
@@ -149,7 +149,7 @@ class API_v3(API_v1):
except Exception as e:
print(e)
print('Upload failed for %s, retrying in 2 seconds' % url)
- time.sleep(2)
+ time.sleep(2 * x + 1)
retry_count -= 1
raise Exception("S3 upload failed")