forked from zaclys/searxng
[fix] timeout and response parsing order
This commit is contained in:
parent
77c3a27f56
commit
789e46f1c8
|
@ -69,6 +69,14 @@ def make_callback(engine_name, results_queue, callback, params):
|
||||||
def process_callback(response, **kwargs):
|
def process_callback(response, **kwargs):
|
||||||
response.search_params = params
|
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
|
# callback
|
||||||
try:
|
try:
|
||||||
search_results = callback(response)
|
search_results = callback(response)
|
||||||
|
@ -81,14 +89,6 @@ def make_callback(engine_name, results_queue, callback, params):
|
||||||
engine_name, str(e))
|
engine_name, str(e))
|
||||||
return
|
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
|
# add results
|
||||||
for result in search_results:
|
for result in search_results:
|
||||||
result['engine'] = engine_name
|
result['engine'] = engine_name
|
||||||
|
|
Loading…
Reference in New Issue