summaryrefslogtreecommitdiff
path: root/searx/network
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-05-19 11:24:18 +0200
committerMarkus Heiser <markus.heiser@darmarit.de>2021-05-22 15:17:18 +0200
commitec834935381e5cfb4ebc3820ed2f668d0fc7855d (patch)
tree352d2253c3dc32f5b62e320537071c00f7b87858 /searx/network
parent2f76b570ab4dae3b2c85aaddddc41831548b1ff8 (diff)
downloadsearxng-ec834935381e5cfb4ebc3820ed2f668d0fc7855d.tar.gz
searxng-ec834935381e5cfb4ebc3820ed2f668d0fc7855d.zip
[fix] offline engine: don't crash on time recording
Diffstat (limited to 'searx/network')
-rw-r--r--searx/network/__init__.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/searx/network/__init__.py b/searx/network/__init__.py
index 981b2261a..587198144 100644
--- a/searx/network/__init__.py
+++ b/searx/network/__init__.py
@@ -44,7 +44,8 @@ def reset_time_for_thread():
def get_time_for_thread():
- return THREADLOCAL.total_time
+ """returns thread's total time or None"""
+ return THREADLOCAL.__dict__.get('total_time')
def set_timeout_for_thread(timeout, start_time=None):
@@ -57,10 +58,11 @@ def set_context_network_name(network_name):
def get_context_network():
- try:
- return THREADLOCAL.network
- except AttributeError:
- return get_network()
+ """If set return thread's network.
+
+ If unset, return value from :py:obj:`get_network`.
+ """
+ return THREADLOCAL.__dict__.get('network') or get_network()
def request(method, url, **kwargs):