summaryrefslogtreecommitdiff
path: root/searx/search.py
diff options
context:
space:
mode:
authorAdam Tauber <adam.tauber@balabit.com>2014-12-18 12:07:20 +0100
committerAdam Tauber <adam.tauber@balabit.com>2014-12-18 12:07:20 +0100
commit789e46f1c8fc7ef705b0d3e9953688eacba8beaf (patch)
tree1da7218202d3b2bea51f11ab57651942ea1679e1 /searx/search.py
parent77c3a27f564c843d420d4d4b9fa3dc8958728fab (diff)
downloadsearxng-789e46f1c8fc7ef705b0d3e9953688eacba8beaf.tar.gz
searxng-789e46f1c8fc7ef705b0d3e9953688eacba8beaf.zip
[fix] timeout and response parsing order
Diffstat (limited to 'searx/search.py')
-rw-r--r--searx/search.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/searx/search.py b/searx/search.py
index 22b0fedb1..064f37220 100644
--- a/searx/search.py
+++ b/searx/search.py
@@ -69,6 +69,14 @@ def make_callback(engine_name, results_queue, callback, params):
def process_callback(response, **kwargs):
response.search_params = params
+ timeout_overhead = 0.2 # seconds
+ search_duration = time() - params['started']
+ timeout_limit = engines[engine_name].timeout + timeout_overhead
+ if search_duration > timeout_limit:
+ engines[engine_name].stats['page_load_time'] += timeout_limit
+ engines[engine_name].stats['errors'] += 1
+ return
+
# callback
try:
search_results = callback(response)
@@ -81,14 +89,6 @@ def make_callback(engine_name, results_queue, callback, params):
engine_name, str(e))
return
- timeout_overhead = 0.2 # seconds
- search_duration = time() - params['started']
- timeout_limit = engines[engine_name].timeout + timeout_overhead
- if search_duration > timeout_limit:
- engines[engine_name].stats['page_load_time'] += timeout_limit
- engines[engine_name].stats['errors'] += 1
- return
-
# add results
for result in search_results:
result['engine'] = engine_name