mirror of
https://github.com/searxng/searxng
synced 2024-01-01 18:24:07 +00:00
[mod] settings_default: remove searx.search.max_request_timeout global variable
This commit is contained in:
parent
4b07df62e5
commit
6fa114c9ba
@ -23,17 +23,6 @@ from searx.search.checker import initialize as initialize_checker
|
||||
|
||||
logger = logger.getChild('search')
|
||||
|
||||
max_request_timeout = settings.get('outgoing', {}).get('max_request_timeout' or None)
|
||||
if max_request_timeout is None:
|
||||
logger.info('max_request_timeout={0}'.format(max_request_timeout))
|
||||
else:
|
||||
if isinstance(max_request_timeout, float):
|
||||
logger.info('max_request_timeout={0} second(s)'.format(max_request_timeout))
|
||||
else:
|
||||
logger.critical('outgoing.max_request_timeout if defined has to be float')
|
||||
import sys
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def initialize(settings_engines=None, enable_checker=False):
|
||||
settings_engines = settings_engines or settings['engines']
|
||||
@ -115,6 +104,7 @@ class Search:
|
||||
default_timeout = max(default_timeout, processor.engine.timeout)
|
||||
|
||||
# adjust timeout
|
||||
max_request_timeout = settings['outgoing']['max_request_timeout']
|
||||
actual_timeout = default_timeout
|
||||
query_timeout = self.search_query.timeout_limit
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
from searx.testing import SearxTestCase
|
||||
from searx.search import SearchQuery, EngineRef
|
||||
from searx import settings
|
||||
import searx.search
|
||||
|
||||
|
||||
@ -41,7 +42,7 @@ class SearchTestCase(SearxTestCase):
|
||||
searx.search.initialize(TEST_ENGINES)
|
||||
|
||||
def test_timeout_simple(self):
|
||||
searx.search.max_request_timeout = None
|
||||
settings['outgoing']['max_request_timeout'] = None
|
||||
search_query = SearchQuery('test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
|
||||
'en-US', SAFESEARCH, PAGENO, None, None)
|
||||
search = searx.search.Search(search_query)
|
||||
@ -49,7 +50,7 @@ class SearchTestCase(SearxTestCase):
|
||||
self.assertEqual(search.actual_timeout, 3.0)
|
||||
|
||||
def test_timeout_query_above_default_nomax(self):
|
||||
searx.search.max_request_timeout = None
|
||||
settings['outgoing']['max_request_timeout'] = None
|
||||
search_query = SearchQuery('test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
|
||||
'en-US', SAFESEARCH, PAGENO, None, 5.0)
|
||||
search = searx.search.Search(search_query)
|
||||
@ -57,7 +58,7 @@ class SearchTestCase(SearxTestCase):
|
||||
self.assertEqual(search.actual_timeout, 3.0)
|
||||
|
||||
def test_timeout_query_below_default_nomax(self):
|
||||
searx.search.max_request_timeout = None
|
||||
settings['outgoing']['max_request_timeout'] = None
|
||||
search_query = SearchQuery('test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
|
||||
'en-US', SAFESEARCH, PAGENO, None, 1.0)
|
||||
search = searx.search.Search(search_query)
|
||||
@ -65,7 +66,7 @@ class SearchTestCase(SearxTestCase):
|
||||
self.assertEqual(search.actual_timeout, 1.0)
|
||||
|
||||
def test_timeout_query_below_max(self):
|
||||
searx.search.max_request_timeout = 10.0
|
||||
settings['outgoing']['max_request_timeout'] = 10.0
|
||||
search_query = SearchQuery('test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
|
||||
'en-US', SAFESEARCH, PAGENO, None, 5.0)
|
||||
search = searx.search.Search(search_query)
|
||||
@ -73,7 +74,7 @@ class SearchTestCase(SearxTestCase):
|
||||
self.assertEqual(search.actual_timeout, 5.0)
|
||||
|
||||
def test_timeout_query_above_max(self):
|
||||
searx.search.max_request_timeout = 10.0
|
||||
settings['outgoing']['max_request_timeout'] = 10.0
|
||||
search_query = SearchQuery('test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
|
||||
'en-US', SAFESEARCH, PAGENO, None, 15.0)
|
||||
search = searx.search.Search(search_query)
|
||||
|
Loading…
Reference in New Issue
Block a user