summaryrefslogtreecommitdiff
path: root/searx/search.py
diff options
context:
space:
mode:
authorThomas Pointhuber <thomas.pointhuber@gmx.at>2015-01-09 21:25:13 +0100
committerThomas Pointhuber <thomas.pointhuber@gmx.at>2015-01-09 21:30:09 +0100
commit400b54191c590663f0cfe91045f70a5d9223aa19 (patch)
tree08c71466ac8fbaf69872f114847baec762f5bd81 /searx/search.py
parentaf8dac93a8acff5042b7b399c38e348f0bdc32ad (diff)
parentc8be128e97479ea6c871c4b6fbf014fa8136e708 (diff)
Merge branch 'master' of https://github.com/asciimoo/searx into code_results
Conflicts: searx/engines/searchcode_code.py searx/engines/searchcode_doc.py searx/static/oscar/js/searx.min.js searx/templates/oscar/result_templates/default.html searx/templates/oscar/result_templates/images.html searx/templates/oscar/result_templates/map.html searx/templates/oscar/result_templates/torrent.html searx/templates/oscar/result_templates/videos.html
Diffstat (limited to 'searx/search.py')
-rw-r--r--searx/search.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/searx/search.py b/searx/search.py
index d1d03805f..f58b6167c 100644
--- a/searx/search.py
+++ b/searx/search.py
@@ -29,21 +29,23 @@ from searx.engines import (
from searx.languages import language_codes
from searx.utils import gen_useragent
from searx.query import Query
+from searx import logger
+logger = logger.getChild('search')
+
number_of_searches = 0
def search_request_wrapper(fn, url, engine_name, **kwargs):
try:
return fn(url, **kwargs)
- except Exception, e:
+ except:
# increase errors stats
engines[engine_name].stats['errors'] += 1
# print engine name and specific error message
- print('[E] Error with engine "{0}":\n\t{1}'.format(
- engine_name, str(e)))
+ logger.exception('engine crash: {0}'.format(engine_name))
return
@@ -66,14 +68,19 @@ def threaded_requests(requests):
remaining_time = max(0.0, timeout_limit - (time() - search_start))
th.join(remaining_time)
if th.isAlive():
- print('engine timeout: {0}'.format(th._engine_name))
-
+ logger.warning('engine timeout: {0}'.format(th._engine_name))
# get default reqest parameter
def default_request_params():
return {
- 'method': 'GET', 'headers': {}, 'data': {}, 'url': '', 'cookies': {}, 'verify': True}
+ 'method': 'GET',
+ 'headers': {},
+ 'data': {},
+ 'url': '',
+ 'cookies': {},
+ 'verify': True
+ }
# create a callback wrapper for the search engine results
@@ -487,14 +494,15 @@ class Search(object):
continue
# append request to list
- requests.append((req, request_params['url'], request_args, selected_engine['name']))
+ requests.append((req, request_params['url'],
+ request_args,
+ selected_engine['name']))
if not requests:
return results, suggestions, answers, infoboxes
# send all search-request
threaded_requests(requests)
-
while not results_queue.empty():
engine_name, engine_results = results_queue.get_nowait()