@@ -73,7 +73,6 @@ def make_callback(engine_name,
74 # creating a callback wrapper for the search engine results
74 # creating a callback wrapper for the search engine results
75 def process_callback(response, **kwargs):
75 def process_callback(response, **kwargs):
77 response.search_params = params
76 response.search_params = params
79 # callback
78 # callback
@@ -82,7 +81,6 @@ def make_callback(engine_name,
82 except Exception, e:
81 except Exception, e:
83 # increase errors stats
82 # increase errors stats
84 engines[engine_name].stats['errors'] += 1
83 engines[engine_name].stats['errors'] += 1
85− results_queue.put_nowait((engine_name, cb_res))
87 # print engine name and specific error message
85 # print engine name and specific error message
88 print '[E] Error with engine "{0}":\n\t{1}'.format(
86 print '[E] Error with engine "{0}":\n\t{1}'.format(
@@ -93,26 +91,7 @@ def make_callback(engine_name,
93 for result in search_results:
91 for result in search_results:
94 result['engine'] = engine_name
92 result['engine'] = engine_name
96− # if it is a suggestion, add it to list of suggestions
97− if 'suggestion' in result:
99− suggestions.add(result['suggestion'])
102− # if it is an answer, add it to list of answers
103− if 'answer' in result:
104− answers.add(result['answer'])
107− # if it is an infobox, add it to list of infoboxes
108− if 'infobox' in result:
109− infoboxes.append(result)
113− cb_res.append(result)
115− results_queue.put_nowait((engine_name, cb_res))
94+ results_queue.put_nowait((engine_name, search_results))
117 # update stats with current page-load-time
96 # update stats with current page-load-time
118 engines[engine_name].stats['page_load_time'] += \
97 engines[engine_name].stats['page_load_time'] += \
@@ -511,8 +490,25 @@ class Search(object):
511 threaded_requests(requests)
490 threaded_requests(requests)
513 results = {}
492 results = {}
514 while not results_queue.empty():
494 while not results_queue.empty():
515 engine_name, engine_results = results_queue.get_nowait()
495 engine_name, engine_results = results_queue.get_nowait()
498+ [suggestions.add(x['suggestion'])
499+ for x in list(engine_results)
500+ if 'suggestion' in x
501+ and engine_results.remove(x) is None]
503+ [answers.add(x['answer'])
504+ for x in list(engine_results)
506+ and engine_results.remove(x) is None]
508+ infoboxes.extend(x for x in list(engine_results)
510+ and engine_results.remove(x) is None)
516 results[engine_name] = engine_results
512 results[engine_name] = engine_results
518 # update engine-specific stats
514 # update engine-specific stats