Bug 1168535 - Re-open the zip file for each upload_symbols retry. r=gps, a=NPOTB
--- a/toolkit/crashreporter/tools/upload_symbols.py
+++ b/toolkit/crashreporter/tools/upload_symbols.py
@@ -41,28 +41,29 @@ def main():
if not os.path.isfile(token_file):
print('Error: SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE "{0}" does not exist!'.format(token_file), file=sys.stderr)
return 1
auth_token = open(token_file, 'r').read().strip()
print('Uploading symbol file "{0}" to "{1}"...'.format(sys.argv[1], url))
- try:
- with redo.retrying(requests.post,
- cleanup=lambda: print('Retrying...'),
- retry_exceptions=(requests.exceptions.RequestException,)) as post:
- r = post(
+ for _ in redo.retrier():
+ try:
+ r = requests.post(
url,
files={'symbols.zip': open(sys.argv[1], 'rb')},
headers={'Auth-Token': auth_token},
allow_redirects=False,
timeout=120)
- except requests.exceptions.RequestException as e:
- print('Error: {0}'.format(e))
+ break
+ except requests.exceptions.RequestException as e:
+ print('Error: {0}'.format(e))
+ else:
+ print('Maximum retries hit, giving up!')
return 1
if r.status_code >= 200 and r.status_code < 300:
print('Uploaded successfully!')
return 0
if r.status_code < 400:
print('Error: bad auth token? ({0}: {1})'.format(r.status_code,