|
@@ -16,8 +16,9 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
|
16
|
16
|
(C) 2013- by Adam Tauber, <asciimoo@gmail.com>
|
17
|
17
|
'''
|
18
|
18
|
|
19
|
|
-from os.path import realpath, dirname
|
20
|
19
|
import sys
|
|
20
|
+import threading
|
|
21
|
+from os.path import realpath, dirname
|
21
|
22
|
from flask_babel import gettext
|
22
|
23
|
from operator import itemgetter
|
23
|
24
|
from json import loads
|
|
@@ -84,6 +85,14 @@ def load_engine(engine_data):
|
84
|
85
|
for engine_attr in dir(engine):
|
85
|
86
|
if engine_attr.startswith('_'):
|
86
|
87
|
continue
|
|
88
|
+ if engine_attr == 'init':
|
|
89
|
+ init_fn = getattr(engine, engine_attr)
|
|
90
|
+ def engine_init():
|
|
91
|
+ init_fn()
|
|
92
|
+ logger.debug('%s engine initialized', engine_data['name'])
|
|
93
|
+ logger.debug('Starting background initialization of %s engine', engine_data['name'])
|
|
94
|
+ threading.Thread(target=engine_init).start()
|
|
95
|
+ continue
|
87
|
96
|
if getattr(engine, engine_attr) is None:
|
88
|
97
|
logger.error('Missing engine config attribute: "{0}.{1}"'
|
89
|
98
|
.format(engine.name, engine_attr))
|