summaryrefslogtreecommitdiff
path: root/searx/network/client.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-04-27 10:03:19 +0200
committerMarkus Heiser <markus.heiser@darmarit.de>2021-04-27 17:47:36 +0200
commit283ae7bfad05fedbf6c7a7e7d7addfc3ae7ed9c7 (patch)
treeb57413a1b766d08e6f40aebe2a166c564fa26213 /searx/network/client.py
parentf724d6f6f1a38d11bc26c39648441bc8788b4288 (diff)
[fix] searx.network: fix rare cases where LOOP is None
* searx.network.client.LOOP is initialized in a thread * searx.network.__init__ imports LOOP which may happen before the thread has initialized LOOP This commit adds a new function "searx.network.client.get_loop()" to fix this issue
Diffstat (limited to 'searx/network/client.py')
-rw-r--r--searx/network/client.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/searx/network/client.py b/searx/network/client.py
index 631e36f8f..b377e010f 100644
--- a/searx/network/client.py
+++ b/searx/network/client.py
@@ -120,7 +120,6 @@ class AsyncHTTPTransportFixed(httpx.AsyncHTTPTransport):
def get_transport_for_socks_proxy(verify, http2, local_address, proxy_url, limit, retries):
- global LOOP, TRANSPORT_KWARGS
# support socks5h (requests compatibility):
# https://requests.readthedocs.io/en/master/user/advanced/#socks
# socks5:// hostname is resolved on client side
@@ -136,7 +135,7 @@ def get_transport_for_socks_proxy(verify, http2, local_address, proxy_url, limit
return AsyncProxyTransportFixed(proxy_type=proxy_type, proxy_host=proxy_host, proxy_port=proxy_port,
username=proxy_username, password=proxy_password,
rdns=rdns,
- loop=LOOP,
+ loop=get_loop(),
verify=verify,
http2=http2,
local_address=local_address,
@@ -192,6 +191,11 @@ def new_client(enable_http, verify, enable_http2,
return httpx.AsyncClient(transport=transport, mounts=mounts, max_redirects=max_redirects)
+def get_loop():
+ global LOOP
+ return LOOP
+
+
def init():
# log
for logger_name in ('hpack.hpack', 'hpack.table'):