summaryrefslogtreecommitdiff
path: root/searx/network
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-04-14 17:23:15 +0200
committerAlexandre Flament <alex@al-f.net>2021-04-21 16:24:46 +0200
commit7acd7ffc02d14d175ec2a99ba984e47d8cb65d7d (patch)
tree000b6e4b0038ed627bb114f8a2de83681bbf7ad4 /searx/network
parentaae7830d14242ac1f98232f428654c5d2c9c5eb2 (diff)
downloadsearxng-7acd7ffc02d14d175ec2a99ba984e47d8cb65d7d.tar.gz
searxng-7acd7ffc02d14d175ec2a99ba984e47d8cb65d7d.zip
[enh] rewrite and enhance metrics
Diffstat (limited to 'searx/network')
-rw-r--r--searx/network/__init__.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/searx/network/__init__.py b/searx/network/__init__.py
index dbd31c781..40665f7d6 100644
--- a/searx/network/__init__.py
+++ b/searx/network/__init__.py
@@ -3,7 +3,7 @@
import asyncio
import threading
import concurrent.futures
-from time import time
+from timeit import default_timer
import httpx
import h2.exceptions
@@ -65,7 +65,7 @@ def get_context_network():
def request(method, url, **kwargs):
"""same as requests/requests/api.py request(...)"""
- time_before_request = time()
+ time_before_request = default_timer()
# timeout (httpx)
if 'timeout' in kwargs:
@@ -82,7 +82,7 @@ def request(method, url, **kwargs):
timeout += 0.2 # overhead
start_time = getattr(THREADLOCAL, 'start_time', time_before_request)
if start_time:
- timeout -= time() - start_time
+ timeout -= default_timer() - start_time
# raise_for_error
check_for_httperror = True
@@ -111,7 +111,7 @@ def request(method, url, **kwargs):
# update total_time.
# See get_time_for_thread() and reset_time_for_thread()
if hasattr(THREADLOCAL, 'total_time'):
- time_after_request = time()
+ time_after_request = default_timer()
THREADLOCAL.total_time += time_after_request - time_before_request
# raise an exception