Bug 1168535 - Re-open the zip file for each upload_symbols retry. r=gps, a=NPOTB
authorTed Mielczarek <ted@mielczarek.org>
Wed, 27 May 2015 14:25:37 -0400
changeset 274919 9c9b478fcb51f2e71935b7749cf09627cdeb6f5b
parent 274918 61093ea985b6d4bc74056ec23e37f43ee205faaa
child 274920 8915466436914a8a52d70d7fc2675cd57143181c
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps, NPOTB
bugs1168535
milestone40.0a2
Bug 1168535 - Re-open the zip file for each upload_symbols retry. r=gps, a=NPOTB
toolkit/crashreporter/tools/upload_symbols.py
--- 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,