diff --git a/aosstower/level_00/influxdb.py b/aosstower/level_00/influxdb.py index 338cdfae627e5f03f5aac8f755fedce17fafa704..0f8392fb771e44786275c119f2e5fc49a5d1a7d1 100644 --- a/aosstower/level_00/influxdb.py +++ b/aosstower/level_00/influxdb.py @@ -246,12 +246,17 @@ def main(): print(url) else: LOG.info("Uploading new data to wunderground...") - resp = requests.post(url) - if resp.status_code != 200: - warnings.warn('Data failed to upload to {0} with status code {1}: {2}'.format( - url, resp.status_code, resp.text)) - else: - LOG.info("Upload successful") + try: + resp = requests.post(url, timeout=15) + if resp.status_code != 200: + LOG.warning('Data failed to upload to {0} with status code {1}: {2}'.format( + url, resp.status_code, resp.text)) + else: + LOG.info("Upload successful") + except requests.Timeout: + LOG.error("Data upload to wunderground timed out", exc_info=True) + except requests.ConnectionError: + LOG.error("Data upload to wunderground had a connection error", exc_info=True) if args.sleep_interval: time.sleep(args.sleep_interval)