From a8797839a10b779bb5b57c27c8e50a48fc9d9a3b Mon Sep 17 00:00:00 2001 From: asciimoo Date: Sun, 3 Nov 2013 00:31:03 +0100 Subject: [PATCH] [enh] request timeout added --- searx/engines/__init__.py | 12 +++++++----- searx/settings.py | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index 29ec5af16..4fc39266e 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -120,16 +120,18 @@ def search(query, request, selected_categories): callback = make_callback(selected_engine['name'], results, engine.response, request_params) if request_params['method'] == 'GET': req = grequests.get(request_params['url'] - ,headers=request_params['headers'] - ,hooks=dict(response=callback) + ,headers = request_params['headers'] + ,hooks = dict(response=callback) ,cookies = request_params['cookies'] + ,timeout = settings.timeout ) else: req = grequests.post(request_params['url'] - ,data=request_params['data'] - ,headers=request_params['headers'] - ,hooks=dict(response=callback) + ,data = request_params['data'] + ,headers = request_params['headers'] + ,hooks = dict(response=callback) ,cookies = request_params['cookies'] + ,timeout = settings.timeout ) requests.append(req) grequests.map(requests) diff --git a/searx/settings.py b/searx/settings.py index 7c3c481e7..3d4e65f06 100644 --- a/searx/settings.py +++ b/searx/settings.py @@ -3,7 +3,9 @@ port = 8888 secret_key = "ultrasecretkey" # change this! -debug = False +debug = True + +request_timeout = 5.0 # seconds weights = {} # 'search_engine_name': float(weight) | default is 1.0