summaryrefslogtreecommitdiff
path: root/searx/network/__init__.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarIT.de>2021-05-22 13:34:44 +0000
committerGitHub <noreply@github.com>2021-05-22 13:34:44 +0000
commit2398e9a1fea6c5c8c2822766d5b0ba38031aec2e (patch)
tree336981aabb7d53f325db95b3ca2729cfb1b6bba3 /searx/network/__init__.py
parent2f76b570ab4dae3b2c85aaddddc41831548b1ff8 (diff)
parent7728e25b11698edd01be048bb8e3b866001cf5c8 (diff)
Merge pull request #85 from searxng/fix-metrics-offline-engine
Fix metrics offline engine
Diffstat (limited to 'searx/network/__init__.py')
-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):