SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[fix] prevent multiple, parallel initializations of tables in the cache DB (#4991)
Markus Heiser2fe8540903c5
diff --git a/searx/data/currencies.py b/searx/data/currencies.pyindex 0721037a1..504f43ae5 100644--- a/searx/data/currencies.py+++ b/searx/data/currencies.py@@ -24,8 +24,9 @@ class CurrenciesDB:def init(self):if self.cache.properties("currencies loaded") != "OK":- self.load()+ # To avoid parallel initializations, the property is set firstself.cache.properties.set("currencies loaded", "OK")+ self.load()# F I X M E:# do we need a maintenance .. rember: database is stored# in /tmp and will be rebuild during the reboot anywaydiff --git a/searx/data/tracker_patterns.py b/searx/data/tracker_patterns.pyindex f269b8395..04776b5a5 100644--- a/searx/data/tracker_patterns.py+++ b/searx/data/tracker_patterns.py@@ -7,7 +7,6 @@ import typing__all__ = ["TrackerPatternsDB"]import re-import pathlibfrom collections.abc import Iteratorfrom urllib.parse import urlparse, urlunparse, parse_qsl, urlencode@@ -22,7 +21,6 @@ class TrackerPatternsDB:# pylint: disable=missing-class-docstringctx_name = "data_tracker_patterns"- json_file = pathlib.Path(__file__).parent / "tracker_patterns.json"CLEAR_LIST_URL = [# ClearURL rule lists, the first one that responds HTTP 200 is used@@ -42,8 +40,9 @@ class TrackerPatternsDB:def init(self):if self.cache.properties("tracker_patterns loaded") != "OK":- self.load()+ # To avoid parallel initializations, the property is set firstself.cache.properties.set("tracker_patterns loaded", "OK")+ self.load()# F I X M E:# do we need a maintenance .. rember: database is stored# in /tmp and will be rebuild during the reboot anywaydiff --git a/searx/plugins/tracker_url_remover.py b/searx/plugins/tracker_url_remover.pyindex b7e8e25f3..190744586 100644--- a/searx/plugins/tracker_url_remover.py+++ b/searx/plugins/tracker_url_remover.py@@ -13,6 +13,7 @@ from searx.data import TRACKER_PATTERNSfrom . import Plugin, PluginInfoif typing.TYPE_CHECKING:+ import flaskfrom searx.search import SearchWithPluginsfrom searx.extended_types import SXNG_Requestfrom searx.result_types import Result, LegacyResult@@ -37,6 +38,10 @@ class SXNGPlugin(Plugin):preference_section="privacy",)+ def init(self, app: "flask.Flask") -> bool:+ TRACKER_PATTERNS.init()+ return True+def on_result(self, request: "SXNG_Request", search: "SearchWithPlugins", result: Result) -> bool:result.filter_urls(self.filter_url_field)diff --git a/searx/search/processors/online_currency.py b/searx/search/processors/online_currency.pyindex 0d7900616..4a56fd05c 100644--- a/searx/search/processors/online_currency.py+++ b/searx/search/processors/online_currency.py@@ -24,6 +24,10 @@ class OnlineCurrencyProcessor(OnlineProcessor):engine_type = 'online_currency'+ def initialize(self):+ CURRENCIES.init()+ super().initialize()+def get_params(self, search_query, engine_category):"""Returns a set of :ref:`request params <engine request online_currency>`or ``None`` if search query does not match to :py:obj:`parser_re`."""