Bug 1252601 - Handle requests errors gracefully when submitting telemetry data r?gps draft
authorDan Minor <dminor@mozilla.com>
Thu, 03 Mar 2016 12:29:46 -0500
changeset 336542 c78a0c64e230f665c7f1bab264c182d0ff4ba857
parent 336498 2b5237c178ea02133a777396c24dd2b713f2b8ee
child 515437 cfadd6a86e9ed7efde8744fdf64546ab93c21e48
push id12109
push userdminor@mozilla.com
push dateThu, 03 Mar 2016 17:33:23 +0000
reviewersgps
bugs1252601
milestone47.0a1
Bug 1252601 - Handle requests errors gracefully when submitting telemetry data r?gps This catches the exception and prevents further attempts to post to telemetry in this command invocation. MozReview-Commit-ID: JDW0zUS8fjF
build/mach_bootstrap.py
--- a/build/mach_bootstrap.py
+++ b/build/mach_bootstrap.py
@@ -370,18 +370,22 @@ def bootstrap(topsrcdir, mozilla_dir=Non
 
         session = requests.Session()
         for filename in os.listdir(outgoing):
             path = os.path.join(outgoing, filename)
             if os.path.isdir(path) or not path.endswith('.json'):
                 continue
             with open(path, 'r') as f:
                 data = f.read()
-                r = session.post(BUILD_TELEMETRY_SERVER, data=data,
-                                 headers={'Content-Type': 'application/json'})
+                try:
+                    r = session.post(BUILD_TELEMETRY_SERVER, data=data,
+                                     headers={'Content-Type': 'application/json'})
+                except Exception as e:
+                    print('Exception posting to telemetry server: %s' % str(e))
+                    break
                 # TODO: some of these errors are likely not recoverable, as
                 # written, we'll retry indefinitely
                 if r.status_code != 200:
                     print('Error posting to telemetry: %s %s' %
                           (r.status_code, r.text))
                     continue
 
             os.rename(os.path.join(outgoing, filename),