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 266148 1f0092bc321a
parent 266147 8b8bd757099b
child 266149 9d21268e218c
push id4766
push userryanvm@gmail.com
push date2015-06-01 16:39 +0000
treeherdermozilla-beta@a2f619521d74 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps, NPOTB
bugs1168535
milestone39.0
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,