Bug 1165347 - Use retries for symbol uploads. r=gps, a=NPOTB
--- a/toolkit/crashreporter/tools/upload_symbols.py
+++ b/toolkit/crashreporter/tools/upload_symbols.py
@@ -10,16 +10,17 @@
# Using this script requires you to have generated an authentication
# token in the crash-stats web interface. You must put the token in a file
# and set SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE to the path to the file in
# the mozconfig you're using.
from __future__ import print_function
import os
+import redo
import requests
import sys
from buildconfig import substs
url = 'https://crash-stats.mozilla.com/symbols/upload'
def main():
@@ -41,23 +42,25 @@ 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:
- r = requests.post(
- url,
- files={'symbols.zip': open(sys.argv[1], 'rb')},
- headers={'Auth-Token': auth_token},
- allow_redirects=False,
- timeout=120,
- )
+ with redo.retrying(requests.post,
+ cleanup=lambda: print('Retrying...'),
+ retry_exceptions=(requests.exceptions.RequestException,)) as post:
+ r = 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))
return 1
if r.status_code >= 200 and r.status_code < 300:
print('Uploaded successfully!')
elif r.status_code < 400:
print('Error: bad auth token? ({0})'.format(r.status_code),