From a8511c9db534faba5562f8777029b72b5ad457cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 12 Sep 2017 16:30:01 +0200 Subject: [PATCH] Gracefully handle read timeouts when communicating with BlenderID --- pillar/api/blender_id.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pillar/api/blender_id.py b/pillar/api/blender_id.py index 01b876ef..d10831ae 100644 --- a/pillar/api/blender_id.py +++ b/pillar/api/blender_id.py @@ -114,9 +114,19 @@ def validate_token(user_id, token, oauth_subclient_id): try: r = s.post(url, data=payload, timeout=5, verify=current_app.config['TLS_CERT_FILE']) - except requests.exceptions.ConnectionError as e: + except requests.exceptions.ConnectionError: log.error('Connection error trying to POST to %s, handling as invalid token.', url) return None, None + except requests.exceptions.ReadTimeout: + log.error('Read timeout trying to POST to %s, handling as invalid token.', url) + return None, None + except requests.exceptions.RequestException as ex: + log.error('Requests error "%s" trying to POST to %s, handling as invalid token.', ex, url) + return None, None + except IOError as ex: + log.error('Unknown I/O error "%s" trying to POST to %s, handling as invalid token.', + ex, url) + return None, None if r.status_code != 200: log.debug('Token %s invalid, HTTP status %i returned', token, r.status_code)