diff --git a/swh/web/admin/deposit.py b/swh/web/admin/deposit.py --- a/swh/web/admin/deposit.py +++ b/swh/web/admin/deposit.py @@ -39,13 +39,15 @@ try: nb_deposits = requests.get('%s?page_size=1' % deposits_list_url, - auth=deposits_list_auth).json()['count'] + auth=deposits_list_auth, + timeout=30).json()['count'] deposits_data = cache.get('swh-deposit-list') if not deposits_data or deposits_data['count'] != nb_deposits: deposits_data = requests.get('%s?page_size=%s' % (deposits_list_url, nb_deposits), - auth=deposits_list_auth).json() + auth=deposits_list_auth, + timeout=30).json() cache.set('swh-deposit-list', deposits_data) deposits = deposits_data['results'] diff --git a/swh/web/common/origin_save.py b/swh/web/common/origin_save.py --- a/swh/web/common/origin_save.py +++ b/swh/web/common/origin_save.py @@ -507,7 +507,8 @@ try: response = requests.post(es_workers_index_url, json={'query': query, - 'sort': ['@timestamp']}) + 'sort': ['@timestamp']}, + timeout=30) results = json.loads(response.text) if results['hits']['total'] >= 1: task_run_info = results['hits']['hits'][-1]['_source'] diff --git a/swh/web/misc/urls.py b/swh/web/misc/urls.py --- a/swh/web/misc/urls.py +++ b/swh/web/misc/urls.py @@ -30,8 +30,11 @@ url = get_config()['history_counters_url'] stat_counters_history = 'null' if url: - response = requests.get(url) - stat_counters_history = response.text + try: + response = requests.get(url, timeout=5) + stat_counters_history = response.text + except Exception: + pass json_data = '{"stat_counters": %s, "stat_counters_history": %s}' % ( json.dumps(stat), stat_counters_history) return HttpResponse(json_data, content_type='application/json')