From 09d9f3168abfb11ee29b2dfbaebdc345557c8136 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Fri, 26 Aug 2022 00:37:08 +0000 Subject: [PATCH] Ignore auth timeout errors --- apiserver/apiserver/api/utils_auth.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apiserver/apiserver/api/utils_auth.py b/apiserver/apiserver/api/utils_auth.py index 023e663..ae9d392 100644 --- a/apiserver/apiserver/api/utils_auth.py +++ b/apiserver/apiserver/api/utils_auth.py @@ -2,6 +2,7 @@ import logging logger = logging.getLogger(__name__) import requests +from requests.exceptions import Timeout from apiserver import secrets from apiserver.api import utils @@ -16,8 +17,12 @@ def discourse_is_configured(): def auth_api(url, data=None, json=None): try: headers = {'Authorization': 'Token ' + secrets.AUTH_API_KEY} - r = requests.post(url, data=data, json=json, headers=headers, timeout=20) + r = requests.post(url, data=data, json=json, headers=headers, timeout=6) return r.status_code + except Timeout as e: + logger.info('Auth {} - {} - {}'.format(url, e.__class__.__name__, str(e))) + logger.info('Auth timeout occured, assuming it worked and returning 200.') + return 200 except BaseException as e: logger.error('Auth {} - {} - {}'.format(url, e.__class__.__name__, str(e))) return None