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 201213 a31be6d7406f81519e9242929701e35450439b61
parent 201212 882d5e18eef435ca158fe906619130ad2c5a068b
child 201214 9a4c377c8a7c2f951b44e3f1d1fdca13e4120576
push id280
push userryanvm@gmail.com
push dateThu, 04 Jun 2015 20:27:19 +0000
treeherdermozilla-esr31@917d8e07d42b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps, NPOTB
bugs1168535
milestone31.7.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,