1
0
Fork 0

utils/community_get_discussion_details: Add a sane request timeout

Signed-off-by: Fabian P. Schmidt <kerel@mailbox.org>
merge-requests/854/head
Fabian P. Schmidt 2019-12-31 03:11:29 +01:00 committed by Pierros Papadeas
parent dd54caa4e4
commit bda0580dbe
2 changed files with 7 additions and 1 deletions

View File

@ -131,7 +131,9 @@ def community_get_discussion_details(
norad_cat_id)
try:
response = requests.get('{}.json'.format(discussion_slug))
response = requests.get(
'{}.json'.format(discussion_slug), timeout=settings.COMMUNITY_TIMEOUT
)
response.raise_for_status()
has_comments = (response.status_code == 200)
except RequestException:

View File

@ -349,6 +349,10 @@ OBS_NO_RESULTS_IGNORE_TIME = config('OBS_NO_RESULTS_IGNORE_TIME', default=1800,
# DB API
DB_API_ENDPOINT = config('DB_API_ENDPOINT', default='https://db.satnogs.org/api/')
# Timeout in seconds for the community forum
# (used e.g. when checking for the existance of certain threads)
COMMUNITY_TIMEOUT = config('COMMUNITY_TIMEOUT', default=2.0, cast=float)
# ListView pagination
ITEMS_PER_PAGE = config('ITEMS_PER_PAGE', default=25, cast=int)