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] lock request pool generator
Adam Tauber357fc47811a1
diff --git a/searx/poolrequests.py b/searx/poolrequests.pyindex c44bdc7e2..4761f6ae8 100644--- a/searx/poolrequests.py+++ b/searx/poolrequests.py@@ -1,5 +1,7 @@import requests+from itertools import cycle+from threading import RLockfrom searx import settings@@ -55,9 +57,10 @@ class SessionSinglePool(requests.Session):super(SessionSinglePool, self).__init__()# reuse the same adapters- self.adapters.clear()- self.mount('https://', next(https_adapters))- self.mount('http://', next(http_adapters))+ with RLock():+ self.adapters.clear()+ self.mount('https://', next(https_adapters))+ self.mount('http://', next(http_adapters))def close(self):"""Call super, but clear adapters since there are managed globaly"""@@ -67,7 +70,6 @@ class SessionSinglePool(requests.Session):def request(method, url, **kwargs):"""same as requests/requests/api.py request(...) except it use SessionSinglePool and force proxies"""- global settingssession = SessionSinglePool()kwargs['proxies'] = settings['outgoing'].get('proxies', None)response = session.request(method=method, url=url, **kwargs)