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
--- 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),